Programming Reference:GenericFileWriter Class

From BCI2000 Wiki
Jump to: navigation, search

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.

For GenericFileWriter descendants, no Process() member function will be called.

See also

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