CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/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       for(auto& slot: iFrom.slots()) {
00062         iTo.connect(slot);
00063       }
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 iFrom  5 6 7 8
00075       // then do the copy to front 8 7 6 5 4 3 2 1
00076 
00077       auto slotsFrom = iFrom.slots();
00078 
00079       std::reverse(slotsFrom.begin(), slotsFrom.end());
00080 
00081       for(auto& slotFrom: slotsFrom) {
00082         iTo.connect_front(slotFrom);
00083       }
00084     }
00085   }
00086 
00087   void
00088   ActivityRegistry::connectGlobals(ActivityRegistry& iOther) {
00089 
00090      postBeginJobSignal_.connect(std::cref(iOther.postBeginJobSignal_));
00091      postEndJobSignal_.connect(std::cref(iOther.postEndJobSignal_));
00092 
00093      jobFailureSignal_.connect(std::cref(iOther.jobFailureSignal_));
00094 
00095      preSourceSignal_.connect(std::cref(iOther.preSourceSignal_));
00096      postSourceSignal_.connect(std::cref(iOther.postSourceSignal_));
00097 
00098      preSourceLumiSignal_.connect(std::cref(iOther.preSourceLumiSignal_));
00099      postSourceLumiSignal_.connect(std::cref(iOther.postSourceLumiSignal_));
00100 
00101      preSourceRunSignal_.connect(std::cref(iOther.preSourceRunSignal_));
00102      postSourceRunSignal_.connect(std::cref(iOther.postSourceRunSignal_));
00103 
00104      preOpenFileSignal_.connect(std::cref(iOther.preOpenFileSignal_));
00105      postOpenFileSignal_.connect(std::cref(iOther.postOpenFileSignal_));
00106 
00107      preCloseFileSignal_.connect(std::cref(iOther.preCloseFileSignal_));
00108      postCloseFileSignal_.connect(std::cref(iOther.postCloseFileSignal_));
00109 
00110      preSourceConstructionSignal_.connect(std::cref(iOther.preSourceConstructionSignal_));
00111      postSourceConstructionSignal_.connect(std::cref(iOther.postSourceConstructionSignal_));
00112 
00113      preProcessEventSignal_.connect(std::cref(iOther.preProcessEventSignal_));
00114      postProcessEventSignal_.connect(std::cref(iOther.postProcessEventSignal_));
00115 
00116      preBeginRunSignal_.connect(std::cref(iOther.preBeginRunSignal_));
00117      postBeginRunSignal_.connect(std::cref(iOther.postBeginRunSignal_));
00118 
00119      preEndRunSignal_.connect(std::cref(iOther.preEndRunSignal_));
00120      postEndRunSignal_.connect(std::cref(iOther.postEndRunSignal_));
00121 
00122      preBeginLumiSignal_.connect(std::cref(iOther.preBeginLumiSignal_));
00123      postBeginLumiSignal_.connect(std::cref(iOther.postBeginLumiSignal_));
00124 
00125      preEndLumiSignal_.connect(std::cref(iOther.preEndLumiSignal_));
00126      postEndLumiSignal_.connect(std::cref(iOther.postEndLumiSignal_));
00127 
00128      preForkReleaseResourcesSignal_.connect(std::cref(iOther.preForkReleaseResourcesSignal_));
00129      postForkReacquireResourcesSignal_.connect(std::cref(iOther.postForkReacquireResourcesSignal_));
00130   }
00131 
00132   void
00133   ActivityRegistry::connectLocals(ActivityRegistry& iOther) {
00134 
00135      preProcessPathSignal_.connect(std::cref(iOther.preProcessPathSignal_));
00136      postProcessPathSignal_.connect(std::cref(iOther.postProcessPathSignal_));
00137 
00138      prePathBeginRunSignal_.connect(std::cref(iOther.prePathBeginRunSignal_));
00139      postPathBeginRunSignal_.connect(std::cref(iOther.postPathBeginRunSignal_));
00140 
00141      prePathEndRunSignal_.connect(std::cref(iOther.prePathEndRunSignal_));
00142      postPathEndRunSignal_.connect(std::cref(iOther.postPathEndRunSignal_));
00143 
00144      prePathBeginLumiSignal_.connect(std::cref(iOther.prePathBeginLumiSignal_));
00145      postPathBeginLumiSignal_.connect(std::cref(iOther.postPathBeginLumiSignal_));
00146 
00147      prePathEndLumiSignal_.connect(std::cref(iOther.prePathEndLumiSignal_));
00148      postPathEndLumiSignal_.connect(std::cref(iOther.postPathEndLumiSignal_));
00149 
00150      preModuleSignal_.connect(std::cref(iOther.preModuleSignal_));
00151      postModuleSignal_.connect(std::cref(iOther.postModuleSignal_));
00152 
00153      preModuleBeginRunSignal_.connect(std::cref(iOther.preModuleBeginRunSignal_));
00154      postModuleBeginRunSignal_.connect(std::cref(iOther.postModuleBeginRunSignal_));
00155 
00156      preModuleEndRunSignal_.connect(std::cref(iOther.preModuleEndRunSignal_));
00157      postModuleEndRunSignal_.connect(std::cref(iOther.postModuleEndRunSignal_));
00158 
00159      preModuleBeginLumiSignal_.connect(std::cref(iOther.preModuleBeginLumiSignal_));
00160      postModuleBeginLumiSignal_.connect(std::cref(iOther.postModuleBeginLumiSignal_));
00161 
00162      preModuleEndLumiSignal_.connect(std::cref(iOther.preModuleEndLumiSignal_));
00163      postModuleEndLumiSignal_.connect(std::cref(iOther.postModuleEndLumiSignal_));
00164 
00165      preModuleConstructionSignal_.connect(std::cref(iOther.preModuleConstructionSignal_));
00166      postModuleConstructionSignal_.connect(std::cref(iOther.postModuleConstructionSignal_));
00167 
00168      preModuleBeginJobSignal_.connect(std::cref(iOther.preModuleBeginJobSignal_));
00169      postModuleBeginJobSignal_.connect(std::cref(iOther.postModuleBeginJobSignal_));
00170 
00171      preModuleEndJobSignal_.connect(std::cref(iOther.preModuleEndJobSignal_));
00172      postModuleEndJobSignal_.connect(std::cref(iOther.postModuleEndJobSignal_));
00173   }
00174 
00175   void
00176   ActivityRegistry::connect(ActivityRegistry& iOther) {
00177     connectGlobals(iOther);
00178     connectLocals(iOther);
00179   }
00180 
00181   void
00182   ActivityRegistry::connectToSubProcess(ActivityRegistry& iOther) {
00183     connectGlobals(iOther);
00184     iOther.connectLocals(*this);
00185   }
00186 
00187   void
00188   ActivityRegistry::copySlotsFrom(ActivityRegistry& iOther) {
00189     copySlotsToFrom(postBeginJobSignal_, iOther.postBeginJobSignal_);
00190     copySlotsToFromReverse(postEndJobSignal_, iOther.postEndJobSignal_);
00191 
00192     copySlotsToFromReverse(jobFailureSignal_, iOther.jobFailureSignal_);
00193 
00194     copySlotsToFrom(preSourceSignal_, iOther.preSourceSignal_);
00195     copySlotsToFromReverse(postSourceSignal_, iOther.postSourceSignal_);
00196 
00197     copySlotsToFrom(preSourceLumiSignal_, iOther.preSourceLumiSignal_);
00198     copySlotsToFromReverse(postSourceLumiSignal_, iOther.postSourceLumiSignal_);
00199 
00200     copySlotsToFrom(preSourceRunSignal_, iOther.preSourceRunSignal_);
00201     copySlotsToFromReverse(postSourceRunSignal_, iOther.postSourceRunSignal_);
00202 
00203     copySlotsToFrom(preOpenFileSignal_, iOther.preOpenFileSignal_);
00204     copySlotsToFromReverse(postOpenFileSignal_, iOther.postOpenFileSignal_);
00205 
00206     copySlotsToFrom(preCloseFileSignal_, iOther.preCloseFileSignal_);
00207     copySlotsToFromReverse(postCloseFileSignal_, iOther.postCloseFileSignal_);
00208 
00209     copySlotsToFrom(preProcessEventSignal_, iOther.preProcessEventSignal_);
00210     copySlotsToFromReverse(postProcessEventSignal_, iOther.postProcessEventSignal_);
00211 
00212     copySlotsToFrom(preBeginRunSignal_, iOther.preBeginRunSignal_);
00213     copySlotsToFromReverse(postBeginRunSignal_, iOther.postBeginRunSignal_);
00214 
00215     copySlotsToFrom(preEndRunSignal_, iOther.preEndRunSignal_);
00216     copySlotsToFromReverse(postEndRunSignal_, iOther.postEndRunSignal_);
00217 
00218     copySlotsToFrom(preBeginLumiSignal_, iOther.preBeginLumiSignal_);
00219     copySlotsToFromReverse(postBeginLumiSignal_, iOther.postBeginLumiSignal_);
00220 
00221     copySlotsToFrom(preEndLumiSignal_, iOther.preEndLumiSignal_);
00222     copySlotsToFromReverse(postEndLumiSignal_, iOther.postEndLumiSignal_);
00223 
00224     copySlotsToFrom(preProcessPathSignal_, iOther.preProcessPathSignal_);
00225     copySlotsToFromReverse(postProcessPathSignal_, iOther.postProcessPathSignal_);
00226 
00227     copySlotsToFrom(prePathBeginRunSignal_, iOther.prePathBeginRunSignal_);
00228     copySlotsToFromReverse(postPathBeginRunSignal_, iOther.postPathBeginRunSignal_);
00229 
00230     copySlotsToFrom(prePathEndRunSignal_, iOther.prePathEndRunSignal_);
00231     copySlotsToFromReverse(postPathEndRunSignal_, iOther.postPathEndRunSignal_);
00232 
00233     copySlotsToFrom(prePathBeginLumiSignal_, iOther.prePathBeginLumiSignal_);
00234     copySlotsToFromReverse(postPathBeginLumiSignal_, iOther.postPathBeginLumiSignal_);
00235 
00236     copySlotsToFrom(prePathEndLumiSignal_, iOther.prePathEndLumiSignal_);
00237     copySlotsToFromReverse(postPathEndLumiSignal_, iOther.postPathEndLumiSignal_);
00238 
00239     copySlotsToFrom(preModuleSignal_, iOther.preModuleSignal_);
00240     copySlotsToFromReverse(postModuleSignal_, iOther.postModuleSignal_);
00241 
00242     copySlotsToFrom(preModuleBeginRunSignal_, iOther.preModuleBeginRunSignal_);
00243     copySlotsToFromReverse(postModuleBeginRunSignal_, iOther.postModuleBeginRunSignal_);
00244 
00245     copySlotsToFrom(preModuleEndRunSignal_, iOther.preModuleEndRunSignal_);
00246     copySlotsToFromReverse(postModuleEndRunSignal_, iOther.postModuleEndRunSignal_);
00247 
00248     copySlotsToFrom(preModuleBeginLumiSignal_, iOther.preModuleBeginLumiSignal_);
00249     copySlotsToFromReverse(postModuleBeginLumiSignal_, iOther.postModuleBeginLumiSignal_);
00250 
00251     copySlotsToFrom(preModuleEndLumiSignal_, iOther.preModuleEndLumiSignal_);
00252     copySlotsToFromReverse(postModuleEndLumiSignal_, iOther.postModuleEndLumiSignal_);
00253 
00254     copySlotsToFrom(preModuleConstructionSignal_, iOther.preModuleConstructionSignal_);
00255     copySlotsToFromReverse(postModuleConstructionSignal_, iOther.postModuleConstructionSignal_);
00256 
00257     copySlotsToFrom(preModuleBeginJobSignal_, iOther.preModuleBeginJobSignal_);
00258     copySlotsToFromReverse(postModuleBeginJobSignal_, iOther.postModuleBeginJobSignal_);
00259 
00260     copySlotsToFrom(preModuleEndJobSignal_, iOther.preModuleEndJobSignal_);
00261     copySlotsToFromReverse(postModuleEndJobSignal_, iOther.postModuleEndJobSignal_);
00262 
00263     copySlotsToFrom(preSourceConstructionSignal_, iOther.preSourceConstructionSignal_);
00264     copySlotsToFromReverse(postSourceConstructionSignal_, iOther.postSourceConstructionSignal_);
00265 
00266     copySlotsToFrom(preForkReleaseResourcesSignal_, iOther.preForkReleaseResourcesSignal_);
00267     copySlotsToFromReverse(postForkReacquireResourcesSignal_, iOther.postForkReacquireResourcesSignal_);
00268   }
00269 
00270   //
00271   // const member functions
00272   //
00273 
00274   //
00275   // static member functions
00276   //
00277 }