<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.bci2000.org/mediawiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Zfreudenburg</id>
	<title>BCI2000 Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.bci2000.org/mediawiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Zfreudenburg"/>
	<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php/Special:Contributions/Zfreudenburg"/>
	<updated>2026-06-10T05:17:55Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:ApplicationBase_Class&amp;diff=6496</id>
		<title>Programming Reference:ApplicationBase Class</title>
		<link rel="alternate" type="text/html" href="https://www.bci2000.org/mediawiki/index.php?title=Programming_Reference:ApplicationBase_Class&amp;diff=6496"/>
		<updated>2012-02-10T18:39:36Z</updated>

		<summary type="html">&lt;p&gt;Zfreudenburg: /* Application Log */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Location==&lt;br /&gt;
&amp;lt;tt&amp;gt;BCI2000/src/shared/modules/application&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Synopsis==&lt;br /&gt;
The &amp;lt;tt&amp;gt;ApplicationBase&amp;lt;/tt&amp;gt; class bundles base functionality which is useful for any BCI2000 application module. This base functionality comprises&lt;br /&gt;
*generation of random numbers,&lt;br /&gt;
*maintaining an application log file, and application log messages to the operator user.&lt;br /&gt;
&lt;br /&gt;
==Usage==&lt;br /&gt;
An application module uses the &amp;lt;tt&amp;gt;ApplicationBase&amp;lt;/tt&amp;gt; class by deriving its [[BCI2000 Glossary#Task|task filter]] from &amp;lt;tt&amp;gt;ApplicationBase&amp;lt;/tt&amp;gt; rather than &amp;lt;tt&amp;gt;GenericFilter&amp;lt;/tt&amp;gt; directly. It has then access to the facilities explained below.&lt;br /&gt;
&lt;br /&gt;
==Access to Application Windows==&lt;br /&gt;
The &amp;lt;tt&amp;gt;ApplicationBase&amp;lt;/tt&amp;gt; class inherits from the [[Programming Reference:ApplicationWindowClient Class|&amp;lt;tt&amp;gt;ApplicationWindowClient&amp;lt;/tt&amp;gt; class]], and thus provides access to framework-managed [[Programming Reference:ApplicationWindow Class|application windows]].&lt;br /&gt;
To access, and possibly create, the main application window from your &amp;lt;tt&amp;gt;ApplicationBase&amp;lt;/tt&amp;gt;-derived application filter class, initialize an &amp;lt;tt&amp;gt;ApplicationWindow&amp;lt;/tt&amp;gt; reference in its constructor with the &amp;lt;tt&amp;gt;ApplicationWindowClient::Window()&amp;lt;/tt&amp;gt; function:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 class MyTaskFilter : public ApplicationBase&lt;br /&gt;
 {&lt;br /&gt;
    ...&lt;br /&gt;
   private:&lt;br /&gt;
    ApplicationWindow&amp;amp; mrWindow;&lt;br /&gt;
    ...&lt;br /&gt;
 };&lt;br /&gt;
&lt;br /&gt;
 MyTaskFilter::MyTaskFilter()&lt;br /&gt;
 : mrWindow( ApplicationWindowClient::Window() )&lt;br /&gt;
 {&lt;br /&gt;
   ...&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 MyTaskFilter::Initialize( ... )&lt;br /&gt;
 {&lt;br /&gt;
   ...&lt;br /&gt;
   ImageStimulus* pImageStimulus = new ImageStimulus( mrWindow );&lt;br /&gt;
   ...&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You may also test windows for existence from the &amp;lt;tt&amp;gt;Preflight()&amp;lt;/tt&amp;gt; function, and only use them when they already exist. This way, your code can adapt to the presence of certain filters in the application module. For more details, see the [[Programming Reference:ApplicationWindowClient Class|&amp;lt;tt&amp;gt;ApplicationWindowClient&amp;lt;/tt&amp;gt; class]] reference page.&lt;br /&gt;
&lt;br /&gt;
==RandomNumberGenerator==&lt;br /&gt;
The &amp;lt;tt&amp;gt;ApplicationBase&amp;lt;/tt&amp;gt; class provides an object of type [[Programming Reference:RandomGenerator Class|&amp;lt;tt&amp;gt;RandomGenerator&amp;lt;/tt&amp;gt;]] which may be used to obtain integer pseudo-random numbers uniformly distributed over a specified range:&lt;br /&gt;
 int rnd = RandomNumberGenerator(10);&lt;br /&gt;
will assign a number between 0 and 9 to the variable named &amp;quot;rnd&amp;quot;.&lt;br /&gt;
Compared with other options to obtain pseudo-random numbers, the advantage of using &amp;lt;tt&amp;gt;ApplicationBase::RandomNumberGenerator&amp;lt;/tt&amp;gt; object is that its behavior is governed by a global random seed value; this allows consistent, predictable BCI2000 behavior, e.g. for testing purposes.&lt;br /&gt;
For more information, refer to the [[Programming Reference:RandomGenerator Class|&amp;lt;tt&amp;gt;RandomGenerator&amp;lt;/tt&amp;gt;]] reference page.&lt;br /&gt;
&lt;br /&gt;
==Application Log==&lt;br /&gt;
Typically, a BCI2000 application module displays messages to the operator user to indicate that a new trial has started, a target has been hit or missed, or to display statistics about the current run. Often, this is information, in conjunction with additional, more detailed information is written into a log file, and that log file is maintained side-by-side with recorded data in the current session directory.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;ApplicationBase&amp;lt;/tt&amp;gt; class provides an object named &amp;lt;tt&amp;gt;AppLog&amp;lt;/tt&amp;gt; as a convenient interface to write messages to screen, log file, or both at the same time. That &amp;lt;tt&amp;gt;AppLog&amp;lt;/tt&amp;gt; object uses a [[Programming Reference:LogFile Class|&amp;lt;tt&amp;gt;LogFile&amp;lt;/tt&amp;gt;]] object to write into a log file; it uses a [[Programming Reference:GenericVisualization Class|&amp;lt;tt&amp;gt;GenericVisualization&amp;lt;/tt&amp;gt;]] object to write messages into an operator window.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;AppLog&amp;lt;/tt&amp;gt; object is a &amp;lt;tt&amp;gt;&amp;lt;std::ostream&amp;gt;&amp;lt;/tt&amp;gt;, and may be used as in the following examples:&lt;br /&gt;
 // Write a message to the log file only&lt;br /&gt;
 AppLog.File &amp;lt;&amp;lt; &amp;quot;This message goes into the log file.&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
&lt;br /&gt;
 // Write a message to the screen only&lt;br /&gt;
 AppLog.Screen &amp;lt;&amp;lt; &amp;quot;This message goes into an operator window.&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
&lt;br /&gt;
 // Write a message to both screen and file:&lt;br /&gt;
 AppLog &amp;lt;&amp;lt; &amp;quot;This message is displayed by the operator module, and written into the log file.&amp;quot; &amp;lt;&amp;lt; endl;&lt;br /&gt;
&lt;br /&gt;
Make sure to include the &amp;quot;endl&amp;quot; as nothing is written until the AppLog receives a newline command.&lt;br /&gt;
&lt;br /&gt;
The application log file is located in the current session directory, and named after the current session; it carries an &#039;&#039;&#039;.applog&#039;&#039;&#039; extension.&lt;br /&gt;
&lt;br /&gt;
Operator log window messages have &#039;&#039;APLG&#039;&#039; as their [[Technical Reference:BCI2000 Messages|visualization source ID]].&lt;br /&gt;
&lt;br /&gt;
==Remarks==&lt;br /&gt;
Typically, a BCI2000 application module will implement a paradigm that belongs to one of two categories:&lt;br /&gt;
*evoking responses using stimulus presentation,&lt;br /&gt;
*continuously presenting feedback of brain activity.&lt;br /&gt;
A BCI2000 task filter implementing one of these paradigms will not inherit from the &amp;lt;tt&amp;gt;ApplicationBase&amp;lt;/tt&amp;gt; directly but either from the [[Programming Reference:StimulusTask Class|StimulusTask]] or [[Programming Reference:FeedbackTask Class|FeedbackTask]].&lt;br /&gt;
Still, such a task filter has access to all functionality provided by &amp;lt;tt&amp;gt;ApplicationBase&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[Programming Reference:StimulusTask Class]], [[Programming Reference:FeedbackTask Class]], [[Programming Reference:ApplicationWindowClient Class]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Framework API]][[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Zfreudenburg</name></author>
	</entry>
</feed>