Programming Reference:Stimulus Class: Difference between revisions
| (5 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
==Location== | ==Stimulus Class== | ||
===Location=== | |||
<tt>src/shared/modules/application/stimuli</tt> | <tt>src/shared/modules/application/stimuli</tt> | ||
==Synopsis== | ===Synopsis=== | ||
The <tt>Stimulus</tt> class is a virtual base class which defines an event handling interface for stimuli. | The <tt>Stimulus</tt> class is a virtual base class which defines an event handling interface for stimuli. | ||
There, a "Stimulus" is defined as "an object that can present (and possibly conceal) itself." | There, a "Stimulus" is defined as "an object that can present (and possibly conceal) itself." | ||
The <tt>Stimulus</tt> class is purely virtual; descendant classes need to implement its <tt>OnPresent()</tt> and <tt>OnConceal()</tt> event handlers. | The <tt>Stimulus</tt> class is purely virtual; descendant classes need to implement its <tt>OnPresent()</tt> and <tt>OnConceal()</tt> event handlers. | ||
An application uses the public <tt>Stimulus::Present()</tt> and <tt>Stimulus::Conceal()</tt> functions to control its behavior; these, in turn, call the virtual event handlers. | |||
The <tt>SetOfStimuli</tt> class allows to define sets of stimuli, and to present or conceal all of the stimuli it contains. | |||
==Properties== | ===Properties=== | ||
===int Tag (rw)=== | ====int Tag (rw)==== | ||
An arbitrary integer that may be used to encode information about a given stimulus (e.g., its corresponding row in a configuration matrix). | An arbitrary integer that may be used to encode information about a given stimulus (e.g., its corresponding row in a configuration matrix). | ||
==Methods== | ===Methods=== | ||
===Present()=== | ====Present()==== | ||
Prompts a stimulus to present itself by calling its <tt>OnPresent()</tt> event handler. | Prompts a stimulus to present itself by calling its <tt>OnPresent()</tt> event handler. | ||
===Conceal()=== | ====Conceal()==== | ||
Prompts a stimulus to conceal itself by calling its <tt>OnConceal()</tt> event handler. | Prompts a stimulus to conceal itself by calling its <tt>OnConceal()</tt> event handler. | ||
==Events== | ===Events=== | ||
===OnPresent=== | ====OnPresent()==== | ||
In its <tt>OnPresent</tt> event handler, a stimulus is supposed to present itself, e.g., to make itself visible, play itself if it is a sound or a movie, or highlight itself if it is a P300 matrix element. | In its <tt>OnPresent</tt> event handler, a stimulus is supposed to present itself, e.g., to make itself visible, play itself if it is a sound or a movie, or highlight itself if it is a P300 matrix element. | ||
===OnConceal=== | ====OnConceal()==== | ||
In its <tt>OnConceal</tt> event handler, a stimulus is supposed to conceal itself, e.g., make itself invisible, or switch back to normal mode. | In its <tt>OnConceal</tt> event handler, a stimulus is supposed to conceal itself, e.g., make itself invisible, or switch back to normal mode. | ||
For non-visual stimuli, this handler is typically empty. | For non-visual stimuli, this handler is typically empty. | ||
| Line 29: | Line 31: | ||
This event is called Conceal rather than Hide because "Hide" is already used as a name for a [[Programming Reference:GraphObject Class|GraphObject]]'s function that makes it invisible. | This event is called Conceal rather than Hide because "Hide" is already used as a name for a [[Programming Reference:GraphObject Class|GraphObject]]'s function that makes it invisible. | ||
==Descendants== | ===Descendants=== | ||
The <tt>Stimulus</tt> class is parent to a class hierarchy containing a number of auditory and visual stimuli: | The <tt>Stimulus</tt> class is parent to a class hierarchy containing a number of auditory and visual stimuli: | ||
<tt> | <tt> | ||
Stimulus |-> [[Programming Reference:VisualStimulus|VisualStimulus]] |-> [[Programming Reference:ImageStimulus|ImageStimulus]] | Stimulus |-> [[Programming Reference:VisualStimulus Class|VisualStimulus]] |-> [[Programming Reference:ImageStimulus Class|ImageStimulus]] | ||
| |-> [[Programming Reference:TextStimulus|TextStimulus]] | | |-> [[Programming Reference:TextStimulus Class|TextStimulus]] | ||
|-> [[Programming Reference:AudioStimulus|AudioStimulus]] | |-> [[Programming Reference:AudioStimulus Class|AudioStimulus]] | ||
|-> [[Programming Reference:SpeechStimulus|SpeechStimulus]] | |-> [[Programming Reference:SpeechStimulus Class|SpeechStimulus]] | ||
|-> [[Programming Reference:SoundStimulus|SoundStimulus]] | |-> [[Programming Reference:SoundStimulus Class|SoundStimulus]] | ||
</tt> | </tt> | ||
==SetOfStimuli Class== | |||
===Location=== | |||
<tt>SetOfStimuli</tt> is declared in the <tt>Stimulus</tt> class header file. | |||
===Synopsis=== | |||
<tt>SetOfStimuli</tt> is a helper class that allows to prompt presentation, concealing, and destruction of a group of stimuli. | |||
===Methods=== | |||
====Add(Stimulus pointer)==== | |||
Adds a stimulus object to the set. | |||
====Remove(Stimulus pointer)==== | |||
Removes a given stimulus object from the set; nothing happens when the specified stimulus is not a member of the set. | |||
====Clear()==== | |||
Clears the set. Stimuli that were represented in the set in form of pointers are unaffected. | |||
====DeleteObjects()==== | |||
Deletes all stimulus objects that are in the set, and clears the set. To avoid dangling pointers, and multiple deletion, you should make sure that the set's members are not part of any other <tt>SetOfStimuli</tt> by the time you call <tt>SetOfStimuli::DeleteObjects()</tt>. | |||
====bool Contains(Stimulus pointer)==== | |||
Returns ''true'' if the specified stimulus object is part of the set, and ''false'' otherwise. | |||
====bool Intersects(SetOfStimuli)==== | |||
Returns ''true'' if any of the elements of the specified set is part of the set on which <tt>Intersects</tt> is called, and ''false'' otherwise. | |||
====Present()==== | |||
Prompts each element of the set to present itself by calling its <tt>Present()</tt> method. | |||
====Conceal()==== | |||
Prompts each element of the set to conceal itself by calling its <tt>Conceal()</tt> method. | |||
==See also== | ==See also== | ||
[[Programming Reference: | [[Programming Reference:AssociationMap Class]], [[Programming Reference:Target Class]], [[Programming Reference:StimulusTask Class]] | ||
[[Programming Reference:AudioStimulus Class]], [[Programming Reference:ImageStimulus Class]], [[Programming Reference:TextStimulus Class]], [[Programming Reference:VisualStimulus Class]], | [[Programming Reference:AudioStimulus Class]], [[Programming Reference:ImageStimulus Class]], [[Programming Reference:TextStimulus Class]], [[Programming Reference:VisualStimulus Class]], | ||
| Line 47: | Line 72: | ||
[[Programming Reference:GraphObject Class]] | [[Programming Reference:GraphObject Class]] | ||
[[Category:Development]][[Category:Framework API]] [[Category:User Application | [[Category:Development]][[Category:Framework API]] [[Category:User Application]] | ||
Latest revision as of 17:45, 10 September 2008
Stimulus Class
Location
src/shared/modules/application/stimuli
Synopsis
The Stimulus class is a virtual base class which defines an event handling interface for stimuli. There, a "Stimulus" is defined as "an object that can present (and possibly conceal) itself."
The Stimulus class is purely virtual; descendant classes need to implement its OnPresent() and OnConceal() event handlers. An application uses the public Stimulus::Present() and Stimulus::Conceal() functions to control its behavior; these, in turn, call the virtual event handlers.
The SetOfStimuli class allows to define sets of stimuli, and to present or conceal all of the stimuli it contains.
Properties
int Tag (rw)
An arbitrary integer that may be used to encode information about a given stimulus (e.g., its corresponding row in a configuration matrix).
Methods
Present()
Prompts a stimulus to present itself by calling its OnPresent() event handler.
Conceal()
Prompts a stimulus to conceal itself by calling its OnConceal() event handler.
Events
OnPresent()
In its OnPresent event handler, a stimulus is supposed to present itself, e.g., to make itself visible, play itself if it is a sound or a movie, or highlight itself if it is a P300 matrix element.
OnConceal()
In its OnConceal event handler, a stimulus is supposed to conceal itself, e.g., make itself invisible, or switch back to normal mode. For non-visual stimuli, this handler is typically empty.
This event is called Conceal rather than Hide because "Hide" is already used as a name for a GraphObject's function that makes it invisible.
Descendants
The Stimulus class is parent to a class hierarchy containing a number of auditory and visual stimuli:
Stimulus |-> VisualStimulus |-> ImageStimulus | |-> TextStimulus |-> AudioStimulus |-> SpeechStimulus |-> SoundStimulus
SetOfStimuli Class
Location
SetOfStimuli is declared in the Stimulus class header file.
Synopsis
SetOfStimuli is a helper class that allows to prompt presentation, concealing, and destruction of a group of stimuli.
Methods
Add(Stimulus pointer)
Adds a stimulus object to the set.
Remove(Stimulus pointer)
Removes a given stimulus object from the set; nothing happens when the specified stimulus is not a member of the set.
Clear()
Clears the set. Stimuli that were represented in the set in form of pointers are unaffected.
DeleteObjects()
Deletes all stimulus objects that are in the set, and clears the set. To avoid dangling pointers, and multiple deletion, you should make sure that the set's members are not part of any other SetOfStimuli by the time you call SetOfStimuli::DeleteObjects().
bool Contains(Stimulus pointer)
Returns true if the specified stimulus object is part of the set, and false otherwise.
bool Intersects(SetOfStimuli)
Returns true if any of the elements of the specified set is part of the set on which Intersects is called, and false otherwise.
Present()
Prompts each element of the set to present itself by calling its Present() method.
Conceal()
Prompts each element of the set to conceal itself by calling its Conceal() method.
See also
Programming Reference:AssociationMap Class, Programming Reference:Target Class, Programming Reference:StimulusTask Class
Programming Reference:AudioStimulus Class, Programming Reference:ImageStimulus Class, Programming Reference:TextStimulus Class, Programming Reference:VisualStimulus Class,