#ifndef BASICCOLL_H #define BASICCOLL_H // BasicColl.h -- Rudimentary test of ELcollected // for use with test of ELrecv // // This header for the example program is in three logical pieces: // // First we show the header for the framework code that would support // various phsyicists' modules. // // Second we show what would typically be in the header for the user code // written by physicists. // // Lastly we place the code setting up the receiving on the server side. // // Portions of the code relevant to the ELcollected mechanism are // pointed out as follows: <<<---------------- // ------------------------------------- // Headers for files making up Framework // ------------------------------------- #include "ErrorLogger/ELcontextSupplier.h" #include "ErrorLogger/ELsender.h" #include #include "ErrorLogger/ErrorLog.h" #include "ZMutility/fstream" class Event; USING( std::string ) USING( std::ofstream ) class ClientContext : public ELcontextSupplier { // $$ 9:1 public: ClientContext ( ); ZM_COVARIANT_TYPE(ELcontextSupplier *, ClientContext *) clone() const; std::string context() const; std::string fullContext() const; std::string summaryContext() const; void advance(); private: int contextNumber; }; // ClientContext // This is the MySender class - not very complicated: class MySender : public ELsender { // <<<---------------- public: MySender ( ofstream & fs ); void send (int nbytes, const char * data); ZM_COVARIANT_TYPE(ELsender *, MySender *) clone() const; protected: ofstream & file; }; class Module { public: Module( const std::string & name ); virtual void operator()( Event & e ) = 0; // do this module's processing! protected: // Note that this is the only line in Module ErrorLog errlog; // inserted because of the ErrorLogger // mechanism! }; // Module // // Event.h // class Event { public: int data; inline Event( int d ) : data(d) { } }; // Event // ----------------------------- // Header for Physicsists' Code // ----------------------------- // // DoPhysics.h -- Many physicists can supply this sort of class // class DoPhysics : public Module { public: inline DoPhysics( const std::string & name ) : Module(name) {} void operator()( Event & event ); }; // DoPhysics // ----------------------------- // Header for Server Code // ----------------------------- #endif /* BASICCOLL_H */