AlgFactory Class Reference

#include <AlgFactory.h>

List of all members.

Public Member Functions

AlgHandle GetAlgHandle (const char *algnm, const char *cnfnm)
ConfigRecordGetOwnedConfigRecord (const VldContext *vld)
void Register (const char *algnm, const char *cnfnm, const char *libnm=0, const char *cclnm=0)

Static Public Member Functions

static AlgFactoryGetInstance ()

Private Member Functions

 AlgFactory ()
virtual ~AlgFactory ()
 AlgFactory (const AlgFactory &)
void operator= (const AlgFactory &)

Private Attributes

TList fAlgHandleList
Bool_t fConfigRecordIsModified

Static Private Attributes

static AlgFactoryfsTheInstance

Friends

struct Cleaner

Classes

struct  Cleaner


Detailed Description

Definition at line 24 of file AlgFactory.h.


Constructor & Destructor Documentation

AlgFactory::AlgFactory (  )  [private]

Definition at line 37 of file AlgFactory.cxx.

References Msg::kDebug, and MSG.

Referenced by GetInstance().

00037                        :
00038   fConfigRecordIsModified(kFALSE)
00039 {
00040    MSG("Alg", Msg::kDebug) << "AlgFactory::Constructor\n";
00041    fsTheInstance = this;
00042 }

AlgFactory::~AlgFactory (  )  [private, virtual]

Definition at line 45 of file AlgFactory.cxx.

References fAlgHandleList, fsTheInstance, Msg::kDebug, and MSG.

00046 {
00047    MSG("Alg", Msg::kDebug) << "AlgFactory::Destructor\n";
00048    fAlgHandleList.Delete();
00049    fsTheInstance = 0;
00050 }

AlgFactory::AlgFactory ( const AlgFactory  )  [private]


Member Function Documentation

AlgHandle AlgFactory::GetAlgHandle ( const char *  algnm,
const char *  cnfnm 
)

Definition at line 68 of file AlgFactory.cxx.

References fAlgHandleList, fConfigRecordIsModified, DbiConfigStream::GetConfigSet(), DynamicPluggableFactory::GetInstance(), gSystem(), DynamicPluggableFactory::IsRegistered(), Msg::kError, Msg::kInfo, DynamicPluggableFactory::LendAlg(), DynamicPluggableFactory::LendAlgConfig(), MSG, and Register().

Referenced by AltDeMuxModule::AltDeMuxModule(), atmo_configure_common(), DmxDeMuxFilterModule::BeginJob(), DigitListModule::BeginJob(), FitTrackMSListModule::Config(), FarDetStripListModule::Config(), FarDetSliceListModule::Config(), FarDetShieldPlankListModule::Config(), Cluster3DModule::Config(), AtNuFitModule::Config(), AtNuFindModule::Config(), AlgEventSSList::CreatePrimaryShower(), AlgEventSRList::CreatePrimaryShower(), FarDetStripListModule::DefaultConfig(), FarDetSliceListModule::DefaultConfig(), FarDetShieldPlankListModule::DefaultConfig(), Cluster3DModule::DefaultConfig(), AtNuFitModule::DefaultConfig(), AtNuFindModule::DefaultConfig(), DmxDeMuxCosmicsModule::DmxDeMuxCosmicsModule(), DmxDeMuxModule::DmxDeMuxModule(), main(), AlgEventSRList::MergeShowers(), TrackSRListModule::Reco(), TrackCamListModule::Reco(), SubShowerSRListModule::Reco(), StripSRListModule::Reco(), SliceSRListModule::Reco(), ShowerSRListModule::Reco(), ShowerEMListModule::Reco(), ShieldPlankListModule::Reco(), RemoveMuon::Reco(), RealCalDetPIDModule::Reco(), MergeEvent::Reco(), FitTrackSRListModule::Reco(), FitTrackSAListModule::Reco(), FitTrackMSListModule::Reco(), FitTrackCamListModule::Reco(), FitShowerEMListModule::Reco(), FilterDigitListModule::Reco(), FarDetStripListModule::Reco(), FarDetSliceListModule::Reco(), FarDetShieldPlankListModule::Reco(), FarDetEventModule::Reco(), FarDetDataQualityModule::Reco(), EventSRListModule::Reco(), DmxDeMuxFilterModule::Reco(), DmxDeMuxCosmicsModule::Reco(), DigitListModule::Reco(), DeMuxDigitListModule::Reco(), DataQualityReader::Reco(), ClusterSRListModule::Reco(), Cluster3DModule::Reco(), ChopModule::Reco(), BiggestChopModule::Reco(), AtNuFitModule::Reco(), AtNuFindModule::Reco(), AtmosShowerListModule::Reco(), AltDeMuxModule::Reco(), AlgEventSSList::ReConstructShowers(), AlgEventSRList::ReConstructShowers(), AlgTrackCamList::RunAlg(), AlgSubShowerSRList::RunAlg(), AlgSliceListFromChopList::RunAlg(), AlgShowerSSList::RunAlg(), AlgShowerEMList::RunAlg(), AlgShieldPlankList::RunAlg(), AlgRmMuList::RunAlg(), AlgMuonRemoval::RunAlg(), AlgMergeEvent::RunAlg(), AlgMCDigitList::RunAlg(), AlgFitTrackSAList::RunAlg(), AlgFitShowerEMList::RunAlg(), AlgFarDetStripList::RunAlg(), AlgFarDetSliceList::RunAlg(), AlgFarDetShieldPlankList::RunAlg(), AlgFarDetDataQuality::RunAlg(), AlgDigitList::RunAlg(), AlgDeMuxDigitList::RunAlg(), AlgDataQuality::RunAlg(), AlgCosmicMuonRemoval::RunAlg(), AlgChopListSharp2::RunAlg(), AlgChopListSharp::RunAlg(), AlgChopListPerfectMC::RunAlg(), AlgChopListMitre::RunAlg(), AlgChopListGeneric::RunAlg(), AlgChopListFar::RunAlg(), AlgCaldetDigitList::RunAlg(), AlgAtNuRecoMCTruth::RunAlg(), AlgAtNuReco::RunAlg(), AlgStripSRList::RunAlgFar(), AlgStripSRList::RunAlgMixed(), AlgStripSRList::RunAlgNear(), AlgSliceSRList::SlicetheSnarl(), AlgSliceSRList::SlicetheSnarl_ASAP(), AlgSliceSRList::SlicetheSnarl_MST(), and StripSRKeyFromTime().

00070 {
00071    const char *algnm = Strip(aalgnm);
00072    const char *cnfnm = Strip(ccnfnm);
00073 
00074    TString regstr(algnm);
00075    regstr = regstr + ":" + cnfnm;
00076    AlgHandle *ah = (AlgHandle *)
00077                                fAlgHandleList.FindObject(regstr.Data());
00078 
00079    if (ah) {
00080      delete [] algnm;  delete [] cnfnm;  // Strip() gives user ownership
00081      return *ah;
00082    }
00083 
00084    DynamicPluggableFactory &dpf =
00085                                  DynamicPluggableFactory::GetInstance();
00086 
00087    Bool_t ljreg = kFALSE;
00088    if ((ljreg = !dpf.IsRegistered(regstr.Data())))
00089                                                  Register(algnm, cnfnm);
00090    AlgBase &ab = dpf.LendAlg(algnm);
00091    AlgConfig &ac = dpf.LendAlgConfig(regstr.Data());
00092    TRef acr = &ac;
00093    ah = new AlgHandle(&ab, acr);
00094 
00095    ah->SetName(regstr.Data());
00096    fAlgHandleList.Add(ah);
00097 
00098    fConfigRecordIsModified = kTRUE;
00099 
00100    if (ljreg) {
00101      TString macroname("DBtxt_");
00102      macroname = macroname + algnm + "_" + cnfnm + ".C";
00103      char *mac = gSystem->Which(gROOT->GetMacroPath(), macroname,
00104                                                        kReadPermission);
00105      if (mac) {
00106        MSG("Alg", Msg::kInfo)
00107                     << "AlgFactory:  (AlgorithmClass:AlgConfigName) = ("
00108            << regstr.Data() << ") parameters set from ROOT macro file: "
00109                                                          << mac << endl;
00110        gROOT->Macro(macroname.Data());
00111      }
00112 
00113      else {            // Get the AlgConfig parameters from the database
00114 
00115 // Here one tries to fill AlgConfig from database.
00116        DbiConfigStream cfstream(algnm,cnfnm);
00117        const DbiConfigSet *cfset = cfstream.GetConfigSet();
00118        if (cfset) {
00119          cfstream >> &ac;            // Get AlgConfig parameters from DB
00120          MSG("Alg", Msg::kInfo)
00121                     << "AlgFactory:  (AlgorithmClass:AlgConfigName) = ("
00122             << regstr.Data() << ") parameters set from DB table entry: "
00123                                        << algnm << "," << cnfnm << endl;
00124        }
00125        else {                               // AlgConfig table not in DB
00126 
00127 // The messages below are printed if the attempt fails.
00128          MSG("Alg", Msg::kError)
00129                     << "AlgFactory:  (AlgorithmClass:AlgConfigName) = ("
00130               << regstr.Data() << ") - failed to find ROOT macro file: "
00131                 << macroname << " in " << gROOT->GetMacroPath() << endl;
00132          MSG("Alg", Msg::kError)
00133                     << "AlgFactory:  (AlgorithmClass:AlgConfigName) = ("
00134            << regstr.Data() << ") parameters not available in database."
00135                              << "  This is likely to be fatal." << endl;
00136        }
00137      }
00138      delete [] mac;      // TSystem::Which() gives ownership to the user
00139    }
00140 
00141    delete [] algnm;  delete [] cnfnm; // Strip() gives ownership to user
00142    return *ah;
00143 }

AlgFactory & AlgFactory::GetInstance (  )  [static]

Definition at line 53 of file AlgFactory.cxx.

References AlgFactory(), fsTheInstance, Msg::kDebug, MSG, and AlgFactory::Cleaner::UseMe().

Referenced by AltDeMuxModule::AltDeMuxModule(), atmo_configure_common(), RealCalDetPIDModule::BeginJob(), DmxDeMuxFilterModule::BeginJob(), DigitListModule::BeginJob(), CalDetSIModule::BeginJob(), AtmosShowerListModule::BeginJob(), AlgEventSSList::BuildEventFromUnassoc(), AlgEventSRList::BuildEventFromUnassoc(), Cluster3DModule::Cluster3DModule(), FitTrackMSListModule::Config(), FarDetStripListModule::Config(), FarDetSliceListModule::Config(), FarDetShieldPlankListModule::Config(), Cluster3DModule::Config(), AtNuFitModule::Config(), AtNuFindModule::Config(), AlgEventSSList::CreatePrimaryShower(), AlgEventSRList::CreatePrimaryShower(), FarDetStripListModule::DefaultConfig(), FarDetSliceListModule::DefaultConfig(), FarDetShieldPlankListModule::DefaultConfig(), Cluster3DModule::DefaultConfig(), AtNuFitModule::DefaultConfig(), AtNuFindModule::DefaultConfig(), DmxDeMuxCosmicsModule::DmxDeMuxCosmicsModule(), DmxDeMuxModule::DmxDeMuxModule(), FitTrackMSListModule::FitTrackMSListModule(), AlgFitTrackCam::GenerateNDSpectStrips(), main(), AlgEventSRList::MergeShowers(), AlgSliceSRList::PassAll(), TrackSRListModule::Reco(), TrackCamListModule::Reco(), SubShowerSRListModule::Reco(), StripSRListModule::Reco(), SliceSRListModule::Reco(), SliceFromChopModule::Reco(), ShowerSRListModule::Reco(), ShowerEMListModule::Reco(), ShieldPlankListModule::Reco(), RemoveMuon::Reco(), RecordSetupModule::Reco(), RealCalDetPIDModule::Reco(), MergeEvent::Reco(), FitTrackSRListModule::Reco(), FitTrackSAListModule::Reco(), FitTrackMSListModule::Reco(), FitTrackCamListModule::Reco(), FitShowerEMListModule::Reco(), FilterDigitListModule::Reco(), FarDetStripListModule::Reco(), FarDetSliceListModule::Reco(), FarDetShieldPlankListModule::Reco(), FarDetEventModule::Reco(), FarDetDataQualityModule::Reco(), EventSRListModule::Reco(), DmxDeMuxFilterModule::Reco(), DmxDeMuxCosmicsModule::Reco(), DigitListModule::Reco(), DeMuxDigitListModule::Reco(), DataQualityReader::Reco(), ClusterSRListModule::Reco(), Cluster3DModule::Reco(), ChopModule::Reco(), CalDetSIModule::Reco(), BiggestChopModule::Reco(), AtNuFitModule::Reco(), AtNuFindModule::Reco(), AtmosShowerListModule::Reco(), AltDeMuxModule::Reco(), AlgEventSSList::ReConstructShowers(), AlgEventSRList::ReConstructShowers(), AlgTrackSRList::RunAlg(), AlgTrackCamList::RunAlg(), AlgTrackAtNuList::RunAlg(), AlgSubShowerSRList::RunAlg(), AlgSliceListFromChopList::RunAlg(), AlgShowerSSList::RunAlg(), AlgShowerSRList::RunAlg(), AlgShowerEMList::RunAlg(), AlgShowerAtNuList::RunAlg(), AlgShieldPlankList::RunAlg(), AlgRmMuList::RunAlg(), AlgMuonRemoval::RunAlg(), AlgMergeEvent::RunAlg(), AlgMCDigitList::RunAlg(), AlgFitTrackSRList::RunAlg(), AlgFitTrackSAList::RunAlg(), AlgFitTrackMSList::RunAlg(), AlgFitTrackCamList::RunAlg(), AlgFitTrackAtNuList::RunAlg(), AlgFitShowerEMList::RunAlg(), AlgFarDetStripList::RunAlg(), AlgFarDetSliceList::RunAlg(), AlgFarDetShieldPlankList::RunAlg(), AlgFarDetEventList::RunAlg(), AlgFarDetDataQuality::RunAlg(), AlgEventSSList::RunAlg(), AlgEventSRList::RunAlg(), AlgDigitList::RunAlg(), AlgDeMuxDigitList::RunAlg(), AlgDataQuality::RunAlg(), AlgCosmicMuonRemoval::RunAlg(), AlgClusterSRList::RunAlg(), AlgCluster3DList::RunAlg(), AlgChopListSharp2::RunAlg(), AlgChopListSharp::RunAlg(), AlgChopListPerfectMC::RunAlg(), AlgChopListMitre::RunAlg(), AlgChopListGeneric::RunAlg(), AlgChopListFar::RunAlg(), AlgCaldetDigitList::RunAlg(), AlgAtNuRecoMCTruth::RunAlg(), AlgAtNuReco::RunAlg(), AlgAtmosShowerList::RunAlg(), AlgStripSRList::RunAlgFar(), AlgStripSRList::RunAlgMixed(), AlgStripSRList::RunAlgNear(), AlgSliceSRList::SlicetheSnarl(), AlgSliceSRList::SlicetheSnarl_ASAP(), AlgSliceSRList::SlicetheSnarl_MST(), AlgTrackSRList::SpectrometerTracking(), and StripSRKeyFromTime().

00054 {
00055 
00056 // Cleaner destructor calls AlgFactory dtor
00057    static Cleaner cleaner;
00058 
00059    if (!fsTheInstance) {
00060      MSG("Alg", Msg::kDebug) << "Instantiating AlgFactory " << endl;
00061      cleaner.UseMe();           // dummy call to quiet compiler warnings
00062      fsTheInstance = new AlgFactory();
00063    }
00064    return *fsTheInstance;
00065 }

ConfigRecord * AlgFactory::GetOwnedConfigRecord ( const VldContext vld  ) 

Definition at line 146 of file AlgFactory.cxx.

References fAlgHandleList, fConfigRecordIsModified, AlgHandle::GetAlgConfig(), RecRecordImp< T >::HasBeenModified(), ConfigRecord::SecureConfig(), and RecRecordImp< T >::SetTransient().

Referenced by RecordSetupModule::Reco().

00147 {
00148 
00149 // Only returns a ConfigRecord when the AlgConfig list has been modified
00150    if (fConfigRecordIsModified == kFALSE) return 0;
00151 
00152 // Create new ConfigRecord for owned return to caller.
00153    const RecHeader rh(*vld);
00154    ConfigRecord *confrec = new ConfigRecord(rh);
00155    confrec->HasBeenModified();
00156    confrec->SetTransient(false);// Record not to be cleared by mom.clear
00157    confrec->SetName("AlgConfigRecord");
00158    confrec->SetTitle("Created by AlgFactory");
00159 
00160 // Add AlgConfigs to new ConfigRecord
00161    TIter algiter(&fAlgHandleList);
00162    AlgHandle *ah = 0;
00163    while ((ah = (AlgHandle *) algiter())) {
00164      confrec->SecureConfig(ah->GetAlgConfig());
00165    }
00166 
00167    fConfigRecordIsModified = kFALSE;
00168    return confrec;
00169 }

void AlgFactory::operator= ( const AlgFactory  )  [private]

void AlgFactory::Register ( const char *  algnm,
const char *  cnfnm,
const char *  libnm = 0,
const char *  cclnm = 0 
)

Definition at line 172 of file AlgFactory.cxx.

References DynamicPluggableFactory::GetInstance(), DynamicPluggableFactory::IsRegistered(), Msg::kDebug, Msg::kWarning, MSG, and DynamicPluggableFactory::Register().

Referenced by AltDeMuxModule::AltDeMuxModule(), atmo_configure_common(), RealCalDetPIDModule::BeginJob(), DmxDeMuxFilterModule::BeginJob(), CalDetSIModule::BeginJob(), AtmosShowerListModule::BeginJob(), Cluster3DModule::Cluster3DModule(), FarDetStripListModule::DefaultConfig(), FarDetSliceListModule::DefaultConfig(), FarDetShieldPlankListModule::DefaultConfig(), AtNuFitModule::DefaultConfig(), AtNuFindModule::DefaultConfig(), DmxDeMuxCosmicsModule::DmxDeMuxCosmicsModule(), DmxDeMuxModule::DmxDeMuxModule(), FitTrackMSListModule::FitTrackMSListModule(), GetAlgHandle(), and main().

00174 {
00175    const char *algnm = Strip(aalgnm);
00176    const char *cnfnm = Strip(ccnfnm);
00177 
00178    TString cclstr(cclnm ? cclnm : "AlgConfig");
00179    TString regstr(algnm);
00180    regstr = regstr + ":" + cnfnm;
00181    DynamicPluggableFactory &dpf =
00182                                  DynamicPluggableFactory::GetInstance();
00183    if (dpf.IsRegistered(regstr.Data())) {
00184      MSG("Alg", Msg::kWarning)
00185        << "AlgFactory:  (AlgorithmClass:AlgConfigName) = ("
00186        << regstr.Data() << ") already registered.  2nd attempt Ignored."
00187        << endl;
00188      delete [] algnm;  delete [] cnfnm;  // Strip() gives user ownership
00189      return;
00190    }
00191 
00192    DynAlgReg *dar = new DynAlgReg(regstr.Data(), algnm, libnm,
00193                                   cclstr.Data());
00194    dpf.Register(dar);
00195 
00196    MSG("Alg", Msg::kDebug)
00197     << "AlgFactory:  Registration of (AlgorithmClass:AlgConfigName) = ("
00198     << regstr.Data() << ") completed." << endl;
00199 
00200    delete [] algnm;  delete [] cnfnm;    // Strip() gives user ownership
00201    return;
00202 }


Friends And Related Function Documentation

friend struct Cleaner [friend]

Definition at line 57 of file AlgFactory.h.


Member Data Documentation

TList AlgFactory::fAlgHandleList [private]

Definition at line 37 of file AlgFactory.h.

Referenced by GetAlgHandle(), GetOwnedConfigRecord(), and ~AlgFactory().

Bool_t AlgFactory::fConfigRecordIsModified [private]

Definition at line 38 of file AlgFactory.h.

Referenced by GetAlgHandle(), and GetOwnedConfigRecord().

AlgFactory * AlgFactory::fsTheInstance [static, private]

Definition at line 36 of file AlgFactory.h.

Referenced by GetInstance(), ~AlgFactory(), and AlgFactory::Cleaner::~Cleaner().


The documentation for this class was generated from the following files:
Generated on Wed Sep 10 22:50:42 2014 for loon by  doxygen 1.4.7