00001 #ifndef FWCore_MessageService_ELcollected_h 00002 #define FWCore_MessageService_ELcollected_h 00003 00004 00005 // ---------------------------------------------------------------------- 00006 // 00007 // ELcollected is a subclass of ELdestination representing a 00008 // destination designed for collection of messages 00009 // from multiple processes. 00010 // 00011 // Usage: 00012 // 00013 // (0) Define "clients" and "server" such that multiple clients each run 00014 // user code which will issue ErrorLogger messages, and a single server 00015 // is to amalgamated those messages into a single flow with unified 00016 // statistics output. 00017 // 00018 // (1) Each client connects (one or more) ELcollected destinations to the 00019 // ELadministrator. These can be controlled in terms of filtering, 00020 // throttling and so forth. The semantics are like those for ELoutput. 00021 // 00022 // (2) When a ELcollected destination is instantiated, the constructor 00023 // takes as an argument an object of a type derived from ELsender. 00024 // ELsender is an abstract class containing a pure virtual method 00025 // send (int n, const char* data). The derived class provides a definition 00026 // of send(n, data) which moves n bytes of data to the server. 00027 // ELsender also has a pure virtual clone() method; 00028 // provision of this follows a boiler-plate we provide. 00029 // One advantage of setting up an ELsender object, rather than making 00030 // the user provide a global-scope function ELsend, is flexibility: 00031 // It makes it trivial to set up two ELcollecteds that send their data to 00032 // two different places or even use two distinct transport mechanisms. 00033 // 00034 // (3) The server process must set up its own ELadministrator, and attach 00035 // whatever destinations it wants to have, such as ELoutput and 00036 // ELstatistics destinations, in the usual manner. 00037 // 00038 // (4a) The server can be set up such that it has an ErrorLog errlog and 00039 // whenever one of these chunks of data is moved to it, it does 00040 // errlog (n, data). 00041 // This is a natural syntax for a framework used to using 00042 // errlog to log messages. If the server process is also doing 00043 // other things that might issue error messages, this syntax 00044 // has the advantageous feature that whatever module name is 00045 // assinged to this errlog, will be prepended to the module name 00046 // sent as part of the message. 00047 // 00048 // (4b) Alternatively, the server cam be set up such that whenever one of these 00049 // chunks of data is moved to it, it calls ELrecv (n, data). 00050 // This may be marginally more convenient. 00051 // 00052 // (*) The effect of an error message on the client is that when the data 00053 // is moved to the server, and that causes ELrecv (or errlog(nbytes,data)) 00054 // to be called, the data is unraveled into the individual items that were 00055 // supplied, and an error message is issued which is identical to the 00056 // error message that was issued on the client. Thus all these messages 00057 // end up amalgamated on the server destination(s). 00058 // 00059 // 2/22/00 mf Created file, based mainly on ELoutput.h 00060 // 3/16/00 mf Mods to support ELsender operation. 00061 // 6/7/00 web Reflect consolidation of ELdestination/X and ELoutput/X 00062 // and consolidate ELcollected/X. 00063 // 6/14/00 web Declare classes before granting friendship. 00064 // 00065 // ---------------------------------------------------------------------- 00066 00067 #include "FWCore/MessageService/interface/ELoutput.h" 00068 #include "FWCore/MessageService/interface/ELsender.h" 00069 00070 #include "FWCore/MessageLogger/interface/ELstring.h" 00071 #include "FWCore/MessageLogger/interface/ELextendedID.h" 00072 00073 #include "boost/shared_ptr.hpp" 00074 00075 namespace edm { 00076 namespace service { 00077 00078 00079 // ---------------------------------------------------------------------- 00080 // prerequisite classes: 00081 // ---------------------------------------------------------------------- 00082 00083 class ELoutput; 00084 class ELdestControl; 00085 00086 00087 // ---------------------------------------------------------------------- 00088 // ELcollected: 00089 // ---------------------------------------------------------------------- 00090 00091 class ELcollected : public ELoutput { 00092 00093 friend class ELdestControl; 00094 00095 public: 00096 00097 // ----- Birth/death: 00098 // 00099 ELcollected( const ELsender & sender ); 00100 ELcollected( const ELcollected & orig ); 00101 ELcollected( ELoutput * d); 00102 virtual ~ELcollected(); 00103 00104 // ----- Methods invoked by the ELadministrator: 00105 // 00106 public: 00107 virtual 00108 ELcollected * 00109 clone() const; 00110 // Used by attach() to put the destination on the ELadministrators list 00111 //-| There is a note in Design Notes about semantics 00112 //-| of copying a destination onto the list: ofstream 00113 //-| ownership is passed to the new copy. 00114 00115 virtual bool log( const edm::ErrorObj & msg ); 00116 00117 // ----- Methods invoked through the ELdestControl handle: 00118 // 00119 protected: 00120 // trivial clearSummary(), wipe(), zero() from base class 00121 // trivial three summary(..) from base class 00122 00123 // ----- Data fundamental to the ELcollected destination: 00124 // 00125 00126 // ----- Data affected by methods of specific ELdestControl handle: 00127 // 00128 protected: 00129 // ELcollected uses the generic ELdestControl handle 00130 00131 // ----- Internal Methods -- Users should not invoke these: 00132 // 00133 protected: 00134 void emitToken( const ELstring & s, bool nl=false ); 00135 00136 boost::shared_ptr<ELsender> sender; 00137 00138 void intoBuf ( const ELstring & s ); 00139 void emitXid ( const ELextendedID & xid ); 00140 00141 ELstring buf; 00142 00143 00144 }; // ELcollected 00145 00146 00147 // ---------------------------------------------------------------------- 00148 00149 00150 } // end of namespace service 00151 } // end of namespace edm 00152 00153 00154 #endif // MessageService_ELcollected_h