Jump to content

Programming Reference:GenericFileWriter Class: Difference between revisions

From BCI2000 Wiki
Mellinger (talk | contribs)
No edit summary
 
Mellinger (talk | contribs)
Line 9: Line 9:
Within the <tt>Publish()</tt> member, parameter and state requests may be specified using the <tt>..._DEFINITIONS</tt> macros as in constructors.
Within the <tt>Publish()</tt> member, parameter and state requests may be specified using the <tt>..._DEFINITIONS</tt> macros as in constructors.
At the beginning of the <tt>Publish()</tt> member function, the inherited implementation of <tt>Publish()</tt> should be called, as in the following example:
At the beginning of the <tt>Publish()</tt> member function, the inherited implementation of <tt>Publish()</tt> should be called, as in the following example:
<pre>
void
BCI2000FileWriter::Publish() const
{
  FileWriterBase::Publish();


void
  BEGIN_PARAMETER_DEFINITIONS
BCI2000FileWriter::Publish() const
    "Storage string StorageTime= % % % % "
{
      "// time of beginning of data storage",
  FileWriterBase::Publish();
  END_PARAMETER_DEFINITIONS
 
}
  BEGIN_PARAMETER_DEFINITIONS
</pre>
    "Storage string StorageTime= % % % % "
      "// time of beginning of data storage",
  END_PARAMETER_DEFINITIONS
}


==<tt>Write()</tt> rather than <tt>Process()</tt>==
==<tt>Write()</tt> rather than <tt>Process()</tt>==

Revision as of 16:04, 7 April 2008

The GenericFileWriter class is a specialization of the GenericFilter class. It is supposed to provide an interface to classes that implement data output into various file formats. Typically, such classes do not inherit from GenericFileWriter directly; rather, they inherit from the FileWriterBase class that additionally implements functionality common to all FileWriters, such as dealing with file naming, location, opening and closing. FileWriterBase maintains an OutputStream property that provides access to a std::ostream object bound to the current output file.

The GenericFileWriter interface is identical to the GenericFilter interface, except for the following:

Publish() member function

Unlike other descendants of GenericFilter, GenericFileWriter descendants are supposed to issue parameter and state requests from a separate Publish() member function rather than their constructors. Within the Publish() member, parameter and state requests may be specified using the ..._DEFINITIONS macros as in constructors. At the beginning of the Publish() member function, the inherited implementation of Publish() should be called, as in the following example:

void
BCI2000FileWriter::Publish() const
{
  FileWriterBase::Publish();

  BEGIN_PARAMETER_DEFINITIONS
    "Storage string StorageTime= % % % % "
      "// time of beginning of data storage",
  END_PARAMETER_DEFINITIONS
}

Write() rather than Process()

Actual data output is supposed to take place from the Write() member function, which receives a GenericSignal and a StateVector argument. There, the state vector argument represents the state vector as it existed at the time when the signal, as provided in the signal argument, was acquired.

See also

Programming Tutorial:Implementing a Data Acquisition Module, Programming Reference:GenericFilter Class