This is a typical ProcessElement, with inputs and outputs and a process step. There are two inputs, and one output port, which has to be created and deleted in the constructor and destructor. It is registered under the name `Output'. The class declaration looks like this:
#include "ProcessElement.h" class DataPort; class BoolPort; class ExampleXorElement : public ProcessElement { public: ExampleXorElement( ); virtual ~ExampleXorElement( ); protected: virtual ProcStatus process( ); virtual bool inputValid( const string& name, DataPort* in, const int idNum ); private: // Outputs (owned) BoolPort* m_outXorResult; // Inputs (not owned) BoolPort* m_inputA; BoolPort* m_inputB; };The only two methods are the usual inputValid, which follows the same principle as the one in ExampleWriter, and the all important process step. The inputValid method allows two connections named `Input0' and `Input1'. The process method checks that the inputs are set, and if so uses their values to derive a result which is set as the value of the output port. This is of course a very simple calculation for an `xor' gate. Thus the actual code for this class is very simple:
m_outXorResult->setBit( m_inputA->getBit() ^ m_inputB->getBit() );