#ifndef TSUSAGE_H #define TSUSAGE_H // TSusage.h -- Illustration of using the basic features of // ThreadSafeErrorLogger mechanism with just 1 thread. // // This header for the example program is in two 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. // // This code is VERY similar to basicUsage.h // Look for // <------ *** to see the modifications // ------------------------------------- // Headers for files making up Framework // ------------------------------------- // // Event.h // // This is a rather lame mock-up of what an Event looks like. // The framework will pass an Event from one module to the next. class Event { public: int data; inline Event( int d ) : data(d) { } }; // Event // --------------------- // // Module.h -- the base class for all physicist modules // // Normally this would include framework.h. // In this illustration that content is in this same file. #ifndef ZMENVIRONMENT_H #include "ZMutility/ZMenvironment.h" #endif #include #include "ErrorLogger/ThreadSafeErrorLog.h" // <------ *** struct BrainDeadMutex { // <------ *** BrainDeadMutex(); // <------ *** ~BrainDeadMutex(); }; // <------ *** class Module { public: Module( const std::string & name ); virtual void operator()( Event & e ) = 0; // do this module's processing! protected: ThreadSafeErrorLog errlog; // <------ *** }; // Module // ----------------------------- // Header for Physicsists' Code // ----------------------------- // // DoPhysics.h -- Many physicists can supply this sort of class // // Normally one would include framework.h. // In this illustration that content is in this same file. // The following are defined in that framework: // class Event; // class Module; // For all these examples, we suppose the physicist will provide code in // the form of a class with an operator() method taking an Event. // That is, the physicist provides a class (DoPhysics in this case) // rather than a global function. // Normally one would include but it is included above in this file. class DoPhysics : public Module { public: inline DoPhysics( const std::string & name ) : Module(name) {} void operator()( Event & event ); // THIS IS WHERE ALL THE PHYSICS // CODE WILL GO. }; // DoPhysics #endif /* TSUSAGE_H */