The header file for the reader looks like this:
#include "ProcessReader.h" class BoolPort; class ExampleReader : public ProcessReader { public: ExampleReader( ); virtual ~ExampleReader( ); protected: virtual ProcStatus readInput( ifstream& file, const FormatType type ); private: // Outputs (owned) BoolPort* m_outA; BoolPort* m_outB; };It is quite a simple class with a constructor, destructor and one method which is invoked to read the file, and set the outputs. There are two outputs, which although logically contained in the class, and with tied lifetimes, are actually declared as pointers. This is to allow forward declaration of BoolPort, rather than inclusion of the header file. This is done to reduce header dependencies. It however does mean that the constructor and destructor have to explicitly create and delete the ports. The constructor also has to register the outputs, which it does with the name `Output' and numbers 0 and 1. The constructor and destructor are really quite trivial.
The final part of the implementation is the file reading. Obviously this
will be very data dependent, but should follow some general rules. The
main purpose is to drive the output ports to the values interpreted
from the file. When
the file is complete, the method should return procEnd to indicate `end
of data'. This will propagate through the simulation and cause it to
return `end of data' to the calling program.