Belle II Software  release-08-01-10
DBAccessorBase Class Reference

Base class for DBObjPtr and DBArray for easier common treatment. More...

#include <DBAccessorBase.h>

Inherited by DBArray< Belle2::TRGECLFAMPara >, DBArray< Belle2::ECLShowerShapeSecondMomentCorrection >, DBArray< Belle2::TOPChannelMap >, DBArray< Belle2::ECLDspData >, DBArray< Belle2::TestCalibObject >, DBArray< Belle2::TOPFrontEndMap >, DBArray< Belle2::CDCFEElectronics >, DBArray< Belle2::CDCDisplacement >, DBArray< Belle2::TRGECLETMPara >, DBArray< Belle2::CDCChannelMap >, DBObjPtr< Belle2::BeamPipeGeo >, DBObjPtr< Belle2::TRGGDLDBAlgs >, DBObjPtr< Belle2::TOPCalFillPatternOffset >, DBObjPtr< Belle2::TOPCalModuleT0 >, DBObjPtr< Belle2::TOPCalChannelRQE >, DBObjPtr< Belle2::SVDRecoConfiguration >, DBObjPtr< Belle2::KLMTimeConversion >, DBObjPtr< Belle2::KLMScintillatorFirmware >, DBObjPtr< Belle2::TRGGDLDBBadrun >, DBObjPtr< Belle2::CDCTimeWalks >, DBObjPtr< Belle2::ARICHGlobalAlignment >, DBObjPtr< Belle2::ARICHChannelMask >, DBObjPtr< Belle2::DBRepresentationOfSoftwareTriggerCut >, DBObjPtr< Belle2::SVDClusterTimeShifter >, DBObjPtr< Belle2::CDCBadWires >, DBObjPtr< Belle2::TOPCalChannelNoise >, DBObjPtr< Belle2::TOPCalChannelPulseHeight >, DBObjPtr< Belle2::SVDGlobalConfigParameters >, DBObjPtr< Belle2::CollisionAxisCMS >, DBObjPtr< Belle2::ECLHadronComponentEmissionFunction >, DBObjPtr< Belle2::CDCTrigger2DConfig >, DBObjPtr< Belle2::CDCDedx1DCell >, DBObjPtr< Belle2::CDCDedxRunGain >, DBObjPtr< Belle2::TOPCalEventT0Offset >, DBObjPtr< Belle2::TOPCalCommonT0 >, DBObjPtr< Belle2::SVDLocalConfigParameters >, DBObjPtr< Belle2::SVDCalibrationsBase >, DBObjPtr< Belle2::BunchStructure >, DBObjPtr< Belle2::ECLTrackClusterMatchingParameterizations >, DBObjPtr< Belle2::CDCDedxSigmaPars >, DBObjPtr< Belle2::CDCDedxMomentumCor >, DBObjPtr< Belle2::HardwareClockSettings >, DBObjPtr< Belle2::CDCPropSpeeds >, DBObjPtr< Belle2::CollisionInvariantMass >, DBObjPtr< Belle2::MagneticField >, DBObjPtr< Belle2::COILGeometryPar >, DBObjPtr< Belle2::SoftwareTriggerMenu >, DBObjPtr< Belle2::SVDSpacePointSNRFractionSelector >, DBObjPtr< Belle2::KLMStripEfficiency >, DBObjPtr< Belle2::CDCCorrToThresholds >, DBObjPtr< Belle2::CDCDedxWireGain >, DBObjPtr< Belle2::CDCCrossTalkLibrary >, DBObjPtr< Belle2::CDCTimeZeros >, DBObjPtr< Belle2::ARICHReconstructionPar >, DBObjPtr< Belle2::PayloadFile >, DBObjPtr< Belle2::KLMElectronicsMap >, DBObjPtr< Belle2::CDCDedx2DCell >, DBObjPtr< Belle2::CDCDedxCosineCor >, DBObjPtr< Belle2::CDCAlignment >, DBObjPtr< Belle2::CDCFudgeFactorsForSigma >, DBObjPtr< Belle2::BeamSpot >, DBObjPtr< Belle2::TOPCalChannelMask >, DBObjPtr< Belle2::ARICHGeometryConfig >, DBObjPtr< Belle2::CDClayerTimeCut >, DBObjPtr< Belle2::TrackFitMomentumRange >, DBObjPtr< Belle2::EventsOfDoomParameters >, DBObjPtr< Belle2::ECLChargedPidPDFs >, DBObjPtr< Belle2::TOPGeometry >, DBObjPtr< Belle2::ROISimulationParameters >, DBObjPtr< Belle2::KLMScintillatorDigitizationParameters >, DBObjPtr< Belle2::KLMTimeCableDelay >, DBObjPtr< Belle2::ECLAutoCovariance >, DBObjPtr< Belle2::TOPCalTimeWalk >, DBObjPtr< Belle2::KLMTimeWindow >, DBObjPtr< Belle2::BeamParameters >, DBObjPtr< Belle2::TRGGDLDBPrescales >, DBObjPtr< Belle2::TOPCalChannelThreshold >, DBObjPtr< Belle2::TOPFrontEndSetting >, DBObjPtr< Belle2::ECLChannelMap >, DBObjPtr< Belle2::ECLReferenceCrystalPerCrateCalib >, DBObjPtr< Belle2::CDCDedxInjectionTime >, DBObjPtr< Belle2::CDCMisalignment >, DBObjPtr< Belle2::ARICHCopperMapping >, DBObjPtr< Belle2::TOPCalModuleAlignment >, DBObjPtr< Belle2::VXDAlignment >, DBObjPtr< Belle2::SVDTimeGroupingConfiguration >, DBObjPtr< Belle2::KLMScintillatorFEEParameters >, DBObjPtr< Belle2::ECLCrystalCalib >, DBObjPtr< Belle2::DAFparameters >, DBObjPtr< Belle2::CDCEDepToADCConversions >, DBObjPtr< Belle2::TOPCalTimebase >, DBObjPtr< Belle2::TOPCalChannelT0 >, DBObjPtr< Belle2::ECLDigitWaveformParametersForMC >, DBObjPtr< Belle2::CDCDedxMeanPars >, DBObjPtr< Belle2::CDCDedxCosineEdge >, DBObjPtr< Belle2::ARICHMergerMapping >, DBObjPtr< Belle2::TestCalibMean >, DBObjPtr< Belle2::TOPCalAsicShift >, DBObjPtr< Belle2::ROICalculationParameters >, DBObjPtr< Belle2::PXDClusterChargeMapPar >, DBObjPtr< Belle2::GeoConfiguration >, DBObjPtr< Belle2::CollisionBoostVector >, DBObjPtr< Belle2::KLMChannelStatus >, DBObjPtr< Belle2::ARICHSimulationPar >, DBObjPtr< Belle2::TRGGDLDBInputBits >, DBObjPtr< Belle2::TRGGDLDBUnpacker >, DBObjPtr< Belle2::ECLTrackClusterMatchingThresholds >, DBObjPtr< Belle2::ECLLeakageCorrections >, DBObjPtr< Belle2::TOPCalChannelThresholdEff >, DBObjPtr< Belle2::TRGGDLDBFTDLBits >, DBObjPtr< Belle2::BKLMSimulationPar >, DBObjPtr< Belle2::CDCTriggerNeuroConfig >, DBObjPtr< Belle2::CDCGeometry >, DBObjPtr< Belle2::ARICHMirrorAlignment >, DBObjPtr< Belle2::ARICHChannelMapping >, DBObjPtr< Belle2::ARICHModulesInfo >, DBObjPtr< Belle2::PXDGainMapPar >, DBObjPtr< Belle2::KLMLikelihoodParameters >, DBObjPtr< Belle2::ECLnOptimal >, DBObjPtr< TTree >, DBObjPtr< Belle2::DedxPDFs >, DBObjPtr< Belle2::CDCDedxHadronCor >, DBObjPtr< Belle2::CDCDedxScaleFactor >, DBObjPtr< Belle2::CDCDedxBadWires >, DBObjPtr< Belle2::CDCADCDeltaPedestals >, DBObjPtr< Belle2::CDCSpaceResols >, DBObjPtr< Belle2::ECLDigitWaveformParameters >, DBObjPtr< Belle2::CDCDedxADCNonLinearity >, DBObjPtr< Belle2::CDCXtRelations >, DBArray< T >, DBObjPtr< T >, DBObjPtr< PayloadFile >, PyDBArray [private], and PyDBObj [private].

Collaboration diagram for DBAccessorBase:

Public Member Functions

 DBAccessorBase (const std::string &name, const TClass *objClass, bool isArray, bool isRequired)
 Constructor to access an object in the DBStore. More...
 
 DBAccessorBase (DBStoreEntry::EPayloadType type, const std::string &name, bool isRequired)
 Constructor to access an object in the DBStore which is not a ROOT Object. More...
 
virtual ~DBAccessorBase ()
 Destructor. More...
 
const std::string & getName () const
 Return name under which the object is saved in the DBStore.
 
bool isValid () const
 Check whether a valid object was obtained from the database. More...
 
 operator bool () const
 Imitate pointer functionality.
 
virtual bool operator== (const DBAccessorBase &other) const
 Check if two store accessors point to the same object/array.
 
virtual bool operator!= (const DBAccessorBase &other) const
 Check if two store accessors point to a different object/array.
 
bool hasChanged ()
 Check whether the object has changed since the last call to hasChanged of the accessor).
 
void addCallback (std::function< void(const std::string &)> callback, bool onDestruction=false)
 Add a callback method. More...
 
void addCallback (std::function< void()> callback, bool onDestruction=false)
 Add a callback method. More...
 
template<class T >
void addCallback (T *object, void(T::*callback)())
 Add a callback method of an object. More...
 
const std::string & getGlobaltag () const
 Return the globaltag name (or testing payloads path) this object is loaded from.
 
unsigned int getRevision () const
 Return current revision of the object.
 
IntervalOfValidity getIoV () const
 Return current IoV of the object.
 
const std::string & getChecksum () const
 Get current checksum.
 
const std::string & getFilename () const
 Get the filename this object is loaded from.
 
bool isIntraRunDependent () const
 Check wether this conditions object has some intra-run dependencies.
 
const std::vector< unsigned int > getIntraRunBoundaries () const
 Get the intra-run boundaries, if any. More...
 
bool isRequired () const
 Check whether this conditions object is required (at least one user declared it as required)
 

Protected Member Functions

template<class T = TObject>
const T * getObject () const
 Return a pointer to the Object already cast to the correct type.
 
bool ensureAttached () const
 Make sure we are attached to the the DBStore. More...
 
void storeEntryChanged (bool destructed)
 Callback function which gets called by the DBStoreEntry object if it changes.
 

Protected Attributes

const DBStoreEntry::EPayloadType m_type
 Type of the payload.
 
const std::string m_name
 Name of the payload in the database.
 
const TClass * m_objClass
 Class of the payload if type is c_Object.
 
const bool m_isArray
 True if the payload is an array of objects.
 
const bool m_isRequired
 True if the payload is required, otherwise no errors will be raised if it cannot be found.
 
DBStoreEntrym_entry
 Pointer to the entry in the DBStore.
 
bool m_changed {false}
 Internal flag whether the object has changed since we last checked.
 
std::vector< std::pair< std::function< void(const std::string &)>, bool > > m_callbacks
 List of all registered callback functions.
 

Friends

class DBStoreEntry
 Allow the DBStoreEntry to call the callback notifier.
 

Detailed Description

Base class for DBObjPtr and DBArray for easier common treatment.

Definition at line 26 of file DBAccessorBase.h.

Constructor & Destructor Documentation

◆ DBAccessorBase() [1/2]

DBAccessorBase ( const std::string &  name,
const TClass *  objClass,
bool  isArray,
bool  isRequired 
)
inline

Constructor to access an object in the DBStore.

Parameters
nameName under which the object is stored in the database (and DBStore).
objClassThe type of the object.
isArrayFlag that indicates whether this is a single object or a TClonesArray.
isRequiredIf true emit errors if the object cannot be found in the Database

Definition at line 36 of file DBAccessorBase.h.

36  :
38  m_entry{DBStore::Instance().getEntry(name, objClass, isArray, isRequired)}, m_changed{isValid()}
39  {
40  if (m_entry) m_entry->registerAccessor(this);
41  }
bool m_changed
Internal flag whether the object has changed since we last checked.
const TClass * m_objClass
Class of the payload if type is c_Object.
bool isValid() const
Check whether a valid object was obtained from the database.
const std::string m_name
Name of the payload in the database.
DBStoreEntry * m_entry
Pointer to the entry in the DBStore.
bool isRequired() const
Check whether this conditions object is required (at least one user declared it as required)
const bool m_isArray
True if the payload is an array of objects.
const DBStoreEntry::EPayloadType m_type
Type of the payload.
const bool m_isRequired
True if the payload is required, otherwise no errors will be raised if it cannot be found.
@ c_Object
A ROOT file containing a object with the name of the DBStoreEntry.
Definition: DBStoreEntry.h:56
void registerAccessor(DBAccessorBase *object)
Register an Accessor object to be notified on changes by calling DBAccessorBase::storeEntryChanged()
Definition: DBStoreEntry.h:123
static DBStore & Instance()
Instance of a singleton DBStore.
Definition: DBStore.cc:28
DBStoreEntry * getEntry(DBStoreEntry::EPayloadType payloadType, const std::string &name, const TClass *objClass, bool array, bool required=true)
Returns the entry with the requested name in the DBStore.
Definition: DBStore.cc:34

◆ DBAccessorBase() [2/2]

DBAccessorBase ( DBStoreEntry::EPayloadType  type,
const std::string &  name,
bool  isRequired 
)
inline

Constructor to access an object in the DBStore which is not a ROOT Object.

Parameters
typeshould be one of c_RootFile or c_RawFile.
nameName under which the object is stored in the database (and DBStore).
isRequiredIf true emit errors if the object cannot be found in the Database

Definition at line 49 of file DBAccessorBase.h.

◆ ~DBAccessorBase()

virtual ~DBAccessorBase ( )
inlinevirtual

Destructor.

Virtual because this is a base class.

Definition at line 60 of file DBAccessorBase.h.

Member Function Documentation

◆ addCallback() [1/3]

void addCallback ( std::function< void()>  callback,
bool  onDestruction = false 
)
inline

Add a callback method.

The given method will be called whenever there is a new database entry for this DBAccessor.

Parameters
callbackfunction pointer to a callback function
onDestructionif true the callback will not be called for each change but only when the Database entry is deleted and can be used to remove dangling pointers to the entry.

Definition at line 118 of file DBAccessorBase.h.

◆ addCallback() [2/3]

void addCallback ( std::function< void(const std::string &)>  callback,
bool  onDestruction = false 
)
inline

Add a callback method.

The given method will be called whenever there is a new database entry for this DBAccessor. The one parameter is the name of the DB entry which changed (in case the same callback method is to be used for multiple payloads.

Parameters
callbackfunction pointer to a callback function
onDestructionif true the callback will not be called for each change but only when the Database entry is deleted and can be used to remove dangling pointers to the entry.

Definition at line 105 of file DBAccessorBase.h.

◆ addCallback() [3/3]

void addCallback ( T *  object,
void(T::*)()  callback 
)
inline

Add a callback method of an object.

The given method will be called whenever there is a new database entry for this DBAccessor.

Parameters
objectThe object with the callback method.
callbackThe callback method.

Definition at line 130 of file DBAccessorBase.h.

◆ ensureAttached()

bool ensureAttached ( ) const
inlineprotected

Make sure we are attached to the the DBStore.

If not try to reconnect

Definition at line 171 of file DBAccessorBase.h.

◆ getIntraRunBoundaries()

const std::vector<unsigned int> getIntraRunBoundaries ( ) const
inline

Get the intra-run boundaries, if any.

If the intra-run dependency is by event number, the event numbers used as boundaries are returned.

Definition at line 157 of file DBAccessorBase.h.

◆ isValid()

bool isValid ( ) const
inline

Check whether a valid object was obtained from the database.

Returns
True if the object exists.

Definition at line 72 of file DBAccessorBase.h.


The documentation for this class was generated from the following file: