CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/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<class 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<class 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::connect(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      preProcessEventSignal_.connect(iOther.preProcessEventSignal_);
00119      postProcessEventSignal_.connect(iOther.postProcessEventSignal_);
00120   
00121      preBeginRunSignal_.connect(iOther.preBeginRunSignal_);
00122      postBeginRunSignal_.connect(iOther.postBeginRunSignal_);
00123   
00124      preEndRunSignal_.connect(iOther.preEndRunSignal_);
00125      postEndRunSignal_.connect(iOther.postEndRunSignal_);
00126   
00127      preBeginLumiSignal_.connect(iOther.preBeginLumiSignal_);
00128      postBeginLumiSignal_.connect(iOther.postBeginLumiSignal_);
00129   
00130      preEndLumiSignal_.connect(iOther.preEndLumiSignal_);
00131      postEndLumiSignal_.connect(iOther.postEndLumiSignal_);
00132   
00133      preProcessPathSignal_.connect(iOther.preProcessPathSignal_);
00134      postProcessPathSignal_.connect(iOther.postProcessPathSignal_);
00135   
00136      prePathBeginRunSignal_.connect(iOther.prePathBeginRunSignal_);
00137      postPathBeginRunSignal_.connect(iOther.postPathBeginRunSignal_);
00138   
00139      prePathEndRunSignal_.connect(iOther.prePathEndRunSignal_);
00140      postPathEndRunSignal_.connect(iOther.postPathEndRunSignal_);
00141   
00142      prePathBeginLumiSignal_.connect(iOther.prePathBeginLumiSignal_);
00143      postPathBeginLumiSignal_.connect(iOther.postPathBeginLumiSignal_);
00144   
00145      prePathEndLumiSignal_.connect(iOther.prePathEndLumiSignal_);
00146      postPathEndLumiSignal_.connect(iOther.postPathEndLumiSignal_);
00147   
00148      preModuleSignal_.connect(iOther.preModuleSignal_);
00149      postModuleSignal_.connect(iOther.postModuleSignal_);
00150   
00151      preModuleBeginRunSignal_.connect(iOther.preModuleBeginRunSignal_);
00152      postModuleBeginRunSignal_.connect(iOther.postModuleBeginRunSignal_);
00153   
00154      preModuleEndRunSignal_.connect(iOther.preModuleEndRunSignal_);
00155      postModuleEndRunSignal_.connect(iOther.postModuleEndRunSignal_);
00156   
00157      preModuleBeginLumiSignal_.connect(iOther.preModuleBeginLumiSignal_);
00158      postModuleBeginLumiSignal_.connect(iOther.postModuleBeginLumiSignal_);
00159   
00160      preModuleEndLumiSignal_.connect(iOther.preModuleEndLumiSignal_);
00161      postModuleEndLumiSignal_.connect(iOther.postModuleEndLumiSignal_);
00162   
00163      preModuleConstructionSignal_.connect(iOther.preModuleConstructionSignal_);
00164      postModuleConstructionSignal_.connect(iOther.postModuleConstructionSignal_);
00165   
00166      preModuleBeginJobSignal_.connect(iOther.preModuleBeginJobSignal_);
00167      postModuleBeginJobSignal_.connect(iOther.postModuleBeginJobSignal_);
00168      
00169      preModuleEndJobSignal_.connect(iOther.preModuleEndJobSignal_);
00170      postModuleEndJobSignal_.connect(iOther.postModuleEndJobSignal_);
00171      
00172      preSourceConstructionSignal_.connect(iOther.preSourceConstructionSignal_);
00173      postSourceConstructionSignal_.connect(iOther.postSourceConstructionSignal_);
00174   
00175      preForkReleaseResourcesSignal_.connect(iOther.preForkReleaseResourcesSignal_);
00176      postForkReacquireResourcesSignal_.connect(iOther.postForkReacquireResourcesSignal_);
00177   }
00178   
00179   void 
00180   ActivityRegistry::copySlotsFrom(ActivityRegistry& iOther) {
00181     copySlotsToFrom(postBeginJobSignal_, iOther.postBeginJobSignal_);
00182     copySlotsToFromReverse(postEndJobSignal_, iOther.postEndJobSignal_);
00183     
00184     copySlotsToFromReverse(jobFailureSignal_, iOther.jobFailureSignal_);
00185     
00186     copySlotsToFrom(preSourceSignal_, iOther.preSourceSignal_);
00187     copySlotsToFromReverse(postSourceSignal_, iOther.postSourceSignal_);
00188   
00189     copySlotsToFrom(preSourceLumiSignal_, iOther.preSourceLumiSignal_);
00190     copySlotsToFromReverse(postSourceLumiSignal_, iOther.postSourceLumiSignal_);
00191   
00192     copySlotsToFrom(preSourceRunSignal_, iOther.preSourceRunSignal_);
00193     copySlotsToFromReverse(postSourceRunSignal_, iOther.postSourceRunSignal_);
00194   
00195     copySlotsToFrom(preOpenFileSignal_, iOther.preOpenFileSignal_);
00196     copySlotsToFromReverse(postOpenFileSignal_, iOther.postOpenFileSignal_);
00197     
00198     copySlotsToFrom(preCloseFileSignal_, iOther.preCloseFileSignal_);
00199     copySlotsToFromReverse(postCloseFileSignal_, iOther.postCloseFileSignal_);
00200     
00201     copySlotsToFrom(preProcessEventSignal_, iOther.preProcessEventSignal_);
00202     copySlotsToFromReverse(postProcessEventSignal_, iOther.postProcessEventSignal_);
00203     
00204     copySlotsToFrom(preBeginRunSignal_, iOther.preBeginRunSignal_);
00205     copySlotsToFromReverse(postBeginRunSignal_, iOther.postBeginRunSignal_);
00206   
00207     copySlotsToFrom(preEndRunSignal_, iOther.preEndRunSignal_);
00208     copySlotsToFromReverse(postEndRunSignal_, iOther.postEndRunSignal_);
00209   
00210     copySlotsToFrom(preBeginLumiSignal_, iOther.preBeginLumiSignal_);
00211     copySlotsToFromReverse(postBeginLumiSignal_, iOther.postBeginLumiSignal_);
00212   
00213     copySlotsToFrom(preEndLumiSignal_, iOther.preEndLumiSignal_);
00214     copySlotsToFromReverse(postEndLumiSignal_, iOther.postEndLumiSignal_);
00215   
00216     copySlotsToFrom(preProcessPathSignal_, iOther.preProcessPathSignal_);
00217     copySlotsToFromReverse(postProcessPathSignal_, iOther.postProcessPathSignal_);
00218   
00219     copySlotsToFrom(prePathBeginRunSignal_, iOther.prePathBeginRunSignal_);
00220     copySlotsToFromReverse(postPathBeginRunSignal_, iOther.postPathBeginRunSignal_);
00221   
00222     copySlotsToFrom(prePathEndRunSignal_, iOther.prePathEndRunSignal_);
00223     copySlotsToFromReverse(postPathEndRunSignal_, iOther.postPathEndRunSignal_);
00224   
00225     copySlotsToFrom(prePathBeginLumiSignal_, iOther.prePathBeginLumiSignal_);
00226     copySlotsToFromReverse(postPathBeginLumiSignal_, iOther.postPathBeginLumiSignal_);
00227   
00228     copySlotsToFrom(prePathEndLumiSignal_, iOther.prePathEndLumiSignal_);
00229     copySlotsToFromReverse(postPathEndLumiSignal_, iOther.postPathEndLumiSignal_);
00230   
00231     copySlotsToFrom(preModuleSignal_, iOther.preModuleSignal_);
00232     copySlotsToFromReverse(postModuleSignal_, iOther.postModuleSignal_);
00233     
00234     copySlotsToFrom(preModuleBeginRunSignal_, iOther.preModuleBeginRunSignal_);
00235     copySlotsToFromReverse(postModuleBeginRunSignal_, iOther.postModuleBeginRunSignal_);
00236     
00237     copySlotsToFrom(preModuleEndRunSignal_, iOther.preModuleEndRunSignal_);
00238     copySlotsToFromReverse(postModuleEndRunSignal_, iOther.postModuleEndRunSignal_);
00239     
00240     copySlotsToFrom(preModuleBeginLumiSignal_, iOther.preModuleBeginLumiSignal_);
00241     copySlotsToFromReverse(postModuleBeginLumiSignal_, iOther.postModuleBeginLumiSignal_);
00242     
00243     copySlotsToFrom(preModuleEndLumiSignal_, iOther.preModuleEndLumiSignal_);
00244     copySlotsToFromReverse(postModuleEndLumiSignal_, iOther.postModuleEndLumiSignal_);
00245     
00246     copySlotsToFrom(preModuleConstructionSignal_, iOther.preModuleConstructionSignal_);
00247     copySlotsToFromReverse(postModuleConstructionSignal_, iOther.postModuleConstructionSignal_);
00248     
00249     copySlotsToFrom(preModuleBeginJobSignal_, iOther.preModuleBeginJobSignal_);
00250     copySlotsToFromReverse(postModuleBeginJobSignal_, iOther.postModuleBeginJobSignal_);
00251     
00252     copySlotsToFrom(preModuleEndJobSignal_, iOther.preModuleEndJobSignal_);
00253     copySlotsToFromReverse(postModuleEndJobSignal_, iOther.postModuleEndJobSignal_);
00254     
00255     copySlotsToFrom(preSourceConstructionSignal_, iOther.preSourceConstructionSignal_);
00256     copySlotsToFromReverse(postSourceConstructionSignal_, iOther.postSourceConstructionSignal_);
00257   
00258     copySlotsToFrom(preForkReleaseResourcesSignal_, iOther.preForkReleaseResourcesSignal_);
00259     copySlotsToFromReverse(postForkReacquireResourcesSignal_, iOther.postForkReacquireResourcesSignal_);
00260   }
00261   
00262   //
00263   // const member functions
00264   //
00265   
00266   //
00267   // static member functions
00268   //
00269 }