CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/FWCore/ServiceRegistry/src/ActivityRegistry.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:     ServiceRegistry
00004 // Class  :     ActivityRegistry
00005 //
00006 // Implementation:
00007 //     <Notes on implementation>
00008 //
00009 // Original Author:  Chris Jones
00010 //         Created:  Tue Sep  6 10:26:49 EDT 2005
00011 //
00012 
00013 // system include files
00014 #include <algorithm>
00015 
00016 // user include files
00017 #include "FWCore/ServiceRegistry/interface/ActivityRegistry.h"
00018 #include "FWCore/Utilities/interface/Algorithms.h"
00019 
00020 //
00021 // constants, enums and typedefs
00022 //
00023 
00024 //
00025 // static data member definitions
00026 //
00027 
00028 //
00029 // constructors and destructor
00030 //
00031 //ActivityRegistry::ActivityRegistry() {
00032 //}
00033 
00034 // ActivityRegistry::ActivityRegistry(ActivityRegistry const& rhs) {
00035 //    // do actual copying here;
00036 // }
00037 
00038 //ActivityRegistry::~ActivityRegistry() {
00039 //}
00040 
00041 //
00042 // assignment operators
00043 //
00044 // ActivityRegistry const& ActivityRegistry::operator=(ActivityRegistry const& rhs) {
00045 //   //An exception safe implementation is
00046 //   ActivityRegistry temp(rhs);
00047 //   swap(rhs);
00048 //
00049 //   return *this;
00050 // }
00051 
00052 //
00053 // member functions
00054 //
00055 namespace edm {
00056   namespace {
00057     template<typename T>
00058     inline
00059     void
00060     copySlotsToFrom(T& iTo, T& iFrom) {
00061       typename T::slot_list_type slots = iFrom.slots();
00062 
00063       for_all(slots, boost::bind(&T::connect, iTo, _1));
00064     }
00065 
00066     template<typename T>
00067     inline
00068     void
00069     copySlotsToFromReverse(T& iTo, T& iFrom) {
00070       // This handles service slots that are supposed to be in reverse
00071       // order of construction. Copying new ones in is a little
00072       // tricky.  Here is an example of what follows
00073       // slots in iTo before  4 3 2 1  and copy in slots in iFrom 8 7 6 5
00074       // reverse both  1 2 3 4  plus 5 6 7 8
00075       // then do the copy 1 2 3 4 5 6 7 8
00076       // then reverse back again to get the desired order
00077       // 8 7 6 5 4 3 2 1
00078 
00079       typename T::slot_list_type slotsFrom = iFrom.slots();
00080       typename T::slot_list_type slotsTo   = iTo.slots();
00081 
00082       std::reverse(slotsTo.begin(), slotsTo.end());
00083       std::reverse(slotsFrom.begin(), slotsFrom.end());
00084 
00085       for_all(slotsFrom, boost::bind(&T::connect, iTo, _1));
00086 
00087       std::reverse(slotsTo.begin(), slotsTo.end());
00088 
00089       // Be nice and put these back in the state they were
00090       // at the beginning
00091       std::reverse(slotsFrom.begin(), slotsFrom.end());
00092     }
00093   }
00094 
00095   void
00096   ActivityRegistry::connectGlobals(ActivityRegistry& iOther) {
00097 
00098      postBeginJobSignal_.connect(iOther.postBeginJobSignal_);
00099      postEndJobSignal_.connect(iOther.postEndJobSignal_);
00100 
00101      jobFailureSignal_.connect(iOther.jobFailureSignal_);
00102 
00103      preSourceSignal_.connect(iOther.preSourceSignal_);
00104      postSourceSignal_.connect(iOther.postSourceSignal_);
00105 
00106      preSourceLumiSignal_.connect(iOther.preSourceLumiSignal_);
00107      postSourceLumiSignal_.connect(iOther.postSourceLumiSignal_);
00108 
00109      preSourceRunSignal_.connect(iOther.preSourceRunSignal_);
00110      postSourceRunSignal_.connect(iOther.postSourceRunSignal_);
00111 
00112      preOpenFileSignal_.connect(iOther.preOpenFileSignal_);
00113      postOpenFileSignal_.connect(iOther.postOpenFileSignal_);
00114 
00115      preCloseFileSignal_.connect(iOther.preCloseFileSignal_);
00116      postCloseFileSignal_.connect(iOther.postCloseFileSignal_);
00117 
00118      preSourceConstructionSignal_.connect(iOther.preSourceConstructionSignal_);
00119      postSourceConstructionSignal_.connect(iOther.postSourceConstructionSignal_);
00120 
00121      preProcessEventSignal_.connect(iOther.preProcessEventSignal_);
00122      postProcessEventSignal_.connect(iOther.postProcessEventSignal_);
00123 
00124      preBeginRunSignal_.connect(iOther.preBeginRunSignal_);
00125      postBeginRunSignal_.connect(iOther.postBeginRunSignal_);
00126 
00127      preEndRunSignal_.connect(iOther.preEndRunSignal_);
00128      postEndRunSignal_.connect(iOther.postEndRunSignal_);
00129 
00130      preBeginLumiSignal_.connect(iOther.preBeginLumiSignal_);
00131      postBeginLumiSignal_.connect(iOther.postBeginLumiSignal_);
00132 
00133      preEndLumiSignal_.connect(iOther.preEndLumiSignal_);
00134      postEndLumiSignal_.connect(iOther.postEndLumiSignal_);
00135 
00136      preForkReleaseResourcesSignal_.connect(iOther.preForkReleaseResourcesSignal_);
00137      postForkReacquireResourcesSignal_.connect(iOther.postForkReacquireResourcesSignal_);
00138   }
00139 
00140   void
00141   ActivityRegistry::connectLocals(ActivityRegistry& iOther) {
00142 
00143      preProcessPathSignal_.connect(iOther.preProcessPathSignal_);
00144      postProcessPathSignal_.connect(iOther.postProcessPathSignal_);
00145 
00146      prePathBeginRunSignal_.connect(iOther.prePathBeginRunSignal_);
00147      postPathBeginRunSignal_.connect(iOther.postPathBeginRunSignal_);
00148 
00149      prePathEndRunSignal_.connect(iOther.prePathEndRunSignal_);
00150      postPathEndRunSignal_.connect(iOther.postPathEndRunSignal_);
00151 
00152      prePathBeginLumiSignal_.connect(iOther.prePathBeginLumiSignal_);
00153      postPathBeginLumiSignal_.connect(iOther.postPathBeginLumiSignal_);
00154 
00155      prePathEndLumiSignal_.connect(iOther.prePathEndLumiSignal_);
00156      postPathEndLumiSignal_.connect(iOther.postPathEndLumiSignal_);
00157 
00158      preModuleSignal_.connect(iOther.preModuleSignal_);
00159      postModuleSignal_.connect(iOther.postModuleSignal_);
00160 
00161      preModuleBeginRunSignal_.connect(iOther.preModuleBeginRunSignal_);
00162      postModuleBeginRunSignal_.connect(iOther.postModuleBeginRunSignal_);
00163 
00164      preModuleEndRunSignal_.connect(iOther.preModuleEndRunSignal_);
00165      postModuleEndRunSignal_.connect(iOther.postModuleEndRunSignal_);
00166 
00167      preModuleBeginLumiSignal_.connect(iOther.preModuleBeginLumiSignal_);
00168      postModuleBeginLumiSignal_.connect(iOther.postModuleBeginLumiSignal_);
00169 
00170      preModuleEndLumiSignal_.connect(iOther.preModuleEndLumiSignal_);
00171      postModuleEndLumiSignal_.connect(iOther.postModuleEndLumiSignal_);
00172 
00173      preModuleConstructionSignal_.connect(iOther.preModuleConstructionSignal_);
00174      postModuleConstructionSignal_.connect(iOther.postModuleConstructionSignal_);
00175 
00176      preModuleBeginJobSignal_.connect(iOther.preModuleBeginJobSignal_);
00177      postModuleBeginJobSignal_.connect(iOther.postModuleBeginJobSignal_);
00178 
00179      preModuleEndJobSignal_.connect(iOther.preModuleEndJobSignal_);
00180      postModuleEndJobSignal_.connect(iOther.postModuleEndJobSignal_);
00181   }
00182 
00183   void
00184   ActivityRegistry::connect(ActivityRegistry& iOther) {
00185     connectGlobals(iOther);
00186     connectLocals(iOther);
00187   }
00188 
00189   void
00190   ActivityRegistry::connectToSubProcess(ActivityRegistry& iOther) {
00191     connectGlobals(iOther);
00192     iOther.connectLocals(*this);
00193   }
00194 
00195   void
00196   ActivityRegistry::copySlotsFrom(ActivityRegistry& iOther) {
00197     copySlotsToFrom(postBeginJobSignal_, iOther.postBeginJobSignal_);
00198     copySlotsToFromReverse(postEndJobSignal_, iOther.postEndJobSignal_);
00199 
00200     copySlotsToFromReverse(jobFailureSignal_, iOther.jobFailureSignal_);
00201 
00202     copySlotsToFrom(preSourceSignal_, iOther.preSourceSignal_);
00203     copySlotsToFromReverse(postSourceSignal_, iOther.postSourceSignal_);
00204 
00205     copySlotsToFrom(preSourceLumiSignal_, iOther.preSourceLumiSignal_);
00206     copySlotsToFromReverse(postSourceLumiSignal_, iOther.postSourceLumiSignal_);
00207 
00208     copySlotsToFrom(preSourceRunSignal_, iOther.preSourceRunSignal_);
00209     copySlotsToFromReverse(postSourceRunSignal_, iOther.postSourceRunSignal_);
00210 
00211     copySlotsToFrom(preOpenFileSignal_, iOther.preOpenFileSignal_);
00212     copySlotsToFromReverse(postOpenFileSignal_, iOther.postOpenFileSignal_);
00213 
00214     copySlotsToFrom(preCloseFileSignal_, iOther.preCloseFileSignal_);
00215     copySlotsToFromReverse(postCloseFileSignal_, iOther.postCloseFileSignal_);
00216 
00217     copySlotsToFrom(preProcessEventSignal_, iOther.preProcessEventSignal_);
00218     copySlotsToFromReverse(postProcessEventSignal_, iOther.postProcessEventSignal_);
00219 
00220     copySlotsToFrom(preBeginRunSignal_, iOther.preBeginRunSignal_);
00221     copySlotsToFromReverse(postBeginRunSignal_, iOther.postBeginRunSignal_);
00222 
00223     copySlotsToFrom(preEndRunSignal_, iOther.preEndRunSignal_);
00224     copySlotsToFromReverse(postEndRunSignal_, iOther.postEndRunSignal_);
00225 
00226     copySlotsToFrom(preBeginLumiSignal_, iOther.preBeginLumiSignal_);
00227     copySlotsToFromReverse(postBeginLumiSignal_, iOther.postBeginLumiSignal_);
00228 
00229     copySlotsToFrom(preEndLumiSignal_, iOther.preEndLumiSignal_);
00230     copySlotsToFromReverse(postEndLumiSignal_, iOther.postEndLumiSignal_);
00231 
00232     copySlotsToFrom(preProcessPathSignal_, iOther.preProcessPathSignal_);
00233     copySlotsToFromReverse(postProcessPathSignal_, iOther.postProcessPathSignal_);
00234 
00235     copySlotsToFrom(prePathBeginRunSignal_, iOther.prePathBeginRunSignal_);
00236     copySlotsToFromReverse(postPathBeginRunSignal_, iOther.postPathBeginRunSignal_);
00237 
00238     copySlotsToFrom(prePathEndRunSignal_, iOther.prePathEndRunSignal_);
00239     copySlotsToFromReverse(postPathEndRunSignal_, iOther.postPathEndRunSignal_);
00240 
00241     copySlotsToFrom(prePathBeginLumiSignal_, iOther.prePathBeginLumiSignal_);
00242     copySlotsToFromReverse(postPathBeginLumiSignal_, iOther.postPathBeginLumiSignal_);
00243 
00244     copySlotsToFrom(prePathEndLumiSignal_, iOther.prePathEndLumiSignal_);
00245     copySlotsToFromReverse(postPathEndLumiSignal_, iOther.postPathEndLumiSignal_);
00246 
00247     copySlotsToFrom(preModuleSignal_, iOther.preModuleSignal_);
00248     copySlotsToFromReverse(postModuleSignal_, iOther.postModuleSignal_);
00249 
00250     copySlotsToFrom(preModuleBeginRunSignal_, iOther.preModuleBeginRunSignal_);
00251     copySlotsToFromReverse(postModuleBeginRunSignal_, iOther.postModuleBeginRunSignal_);
00252 
00253     copySlotsToFrom(preModuleEndRunSignal_, iOther.preModuleEndRunSignal_);
00254     copySlotsToFromReverse(postModuleEndRunSignal_, iOther.postModuleEndRunSignal_);
00255 
00256     copySlotsToFrom(preModuleBeginLumiSignal_, iOther.preModuleBeginLumiSignal_);
00257     copySlotsToFromReverse(postModuleBeginLumiSignal_, iOther.postModuleBeginLumiSignal_);
00258 
00259     copySlotsToFrom(preModuleEndLumiSignal_, iOther.preModuleEndLumiSignal_);
00260     copySlotsToFromReverse(postModuleEndLumiSignal_, iOther.postModuleEndLumiSignal_);
00261 
00262     copySlotsToFrom(preModuleConstructionSignal_, iOther.preModuleConstructionSignal_);
00263     copySlotsToFromReverse(postModuleConstructionSignal_, iOther.postModuleConstructionSignal_);
00264 
00265     copySlotsToFrom(preModuleBeginJobSignal_, iOther.preModuleBeginJobSignal_);
00266     copySlotsToFromReverse(postModuleBeginJobSignal_, iOther.postModuleBeginJobSignal_);
00267 
00268     copySlotsToFrom(preModuleEndJobSignal_, iOther.preModuleEndJobSignal_);
00269     copySlotsToFromReverse(postModuleEndJobSignal_, iOther.postModuleEndJobSignal_);
00270 
00271     copySlotsToFrom(preSourceConstructionSignal_, iOther.preSourceConstructionSignal_);
00272     copySlotsToFromReverse(postSourceConstructionSignal_, iOther.postSourceConstructionSignal_);
00273 
00274     copySlotsToFrom(preForkReleaseResourcesSignal_, iOther.preForkReleaseResourcesSignal_);
00275     copySlotsToFromReverse(postForkReacquireResourcesSignal_, iOther.postForkReacquireResourcesSignal_);
00276   }
00277 
00278   //
00279   // const member functions
00280   //
00281 
00282   //
00283   // static member functions
00284   //
00285 }