// frame1.cc -- Framework parts of test of basic step1 // implementation of ErrorLogger mechanism. // // The strange comments like // $$ 9:3 refer to the fact that this line // excercises something in section 9 (for example) of the semantics design. #ifndef ZMENVIRONMENT_H #include "ZMutility/ZMenvironment.h" #endif #include "ErrorLogger/ELadministrator.h" #include "ErrorLogger/ELdestControl.h" #include "ErrorLogger/ELoutput.h" #include "ErrorLogger/ELstatistics.h" #include "ZMutility/iostream" USING( std::cin ) USING( std::cout ) USING( std::endl ) USING( std::flush ) #include "ZMutility/iomanip" USING( std::setw ) #ifndef SSTREAM_INCLUDED #include "ZMutility/sstream" #endif USING( std::ostringstream ) #include USING( std::string ) #include "Module1.h" #include "FindTracks1.h" #include "DoPhysics1.h" ZM_USING_NAMESPACE( zmel ) /* using zmel; */ //============================================================================= // // Classes the Framework Makes Available // //============================================================================= ZM_COVARIANT_TYPE(ELcontextSupplier *, RunEventContext *) // $$ 12:1 RunEventContext::clone() const { return new RunEventContext( *this ); } // $$ 9:1 string RunEventContext::context() const { ostringstream ev; ev << " event = " << FindTracks::event_counter(); return ev.str(); } // $$ 9:1 string RunEventContext::fullContext() const { return context(); } // $$ 9:1 string RunEventContext::summaryContext() const { return context(); } // $$ 9:1 //============================================================================= // // FRAMEWORK // //============================================================================= // The framework: // * Defines a class Event (above) // * Provides an ELcontextSupplier (above) // * Sets up a pure virtual base class Module (in module1.cc) // * Knows which classes derived from Module exist // * Contains main() which instantiates and invokes each of the // various modules // // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - int main() { ELadministrator * logger = ELadministrator::instance(); // $$ 9:2 // instantiate a logger object RunEventContext reContext; // instantiate an ELcontextSupplier logger->setContextSupplier( reContext ); // tell the logger about it // $$ 9:3 logger->setAbortThreshold( ELabort ); // $$ 14:1 // logger is to shut us down at this severity or worse ELoutput logfileD( "myLogFile.frame1" ); // make the first ELdestination // $$ 9:5 ELdestControl logfile ( logger->attach(logfileD) );// tell the logger about it // $$ 9:6 logfile.setThreshold ( ELsuccess ); // ignore messages below this severity // $$ 9:7 ELoutput outputD( cout ); // make the second ELdestination // $$ 9:8 ELdestControl output ( logger->attach(outputD) ); // tell the logger about it // $$ 9:9 output.setThreshold ( ELwarning ); // ignore messages below this severity // $$ 9:7 ELstatistics statsD( cout ); // $$ 9:10 ELdestControl stats ( logger->attach(statsD) ); // $$ 9:6 ErrorLog errlog; errlog.setModule( "framework" ); // $$ 11:1 // The following is a list of the modules in this program: FindTracks findTracks( "TRACK FINDER" ); DoPhysics doPhysics( "PHYSICS CODE" ); int n; for ( n = 1; n < 10; ++n ) { Event event( n ); errlog( ELinfo, "Event Number " ) << n << endmsg; // $$ 2:1 findTracks( event ); doPhysics( event ); cout << "data returns as " << event.data << "\n\n"; } errlog( ELsevere, "It's almost time to abort" ) << "n = " << n << endmsg; // $$ 14:1 // $$ 2:5 stats.summary( output, "Framework Title" ); // $$ 15:1 // $$ 6:1 // $$ 6:2 errlog( ELabort, "It's time to abort" ) << "n = " << n << endmsg; // $$ 14:1 return 0; } // main() #include "Module1.cc" #include "FindTracks1.cc" #include "DoPhysics1.cc"