Belle II Software development
StoreObjPtr< T > Class Template Reference

Type-safe access to single objects in the data store. More...

#include <StoreObjPtr.h>

Inheritance diagram for StoreObjPtr< T >:
StoreAccessorBase StoreWrappedObjPtr< std::vector< Belle2::TrackFindingCDC::CDCTrack > > StoreWrappedObjPtr< std::vector< Belle2::TrackFindingCDC::CDCWireHit > >

Public Member Functions

 StoreObjPtr (const std::string &name="", DataStore::EDurability durability=DataStore::c_Event)
 Constructor to access an object in the DataStore.
 
bool isValid () const
 Check whether the object was created.
 
template<class ... Args>
bool construct (Args &&... params)
 Construct an object of type T in this StoreObjPtr, using the provided constructor arguments.
 
template<class ... Args>
bool constructAndReplace (Args &&... params)
 Construct an object of type T in this StoreObjPtr, using the provided constructor arguments.
 
T & operator* () const
 Imitate pointer functionality.
 
T * operator-> () const
 Imitate pointer functionality.
 
 operator bool () const
 Imitate pointer functionality.
 
bool registerInDataStore (DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
 Register the object/array in the DataStore.
 
bool registerInDataStore (const std::string &name, DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
 Register the object/array in the DataStore.
 
bool isRequired (const std::string &name="")
 Ensure this array/object has been registered previously.
 
bool isOptional (const std::string &name="")
 Tell the DataStore about an optional input.
 
bool create (bool replace=false)
 Create a default object in the data store.
 
bool assign (TObject *object, bool replace=false)
 Assign 'object' to this accessor.
 
virtual void clear ()
 Clear contents of this object.
 
const std::string & getName () const
 Return name under which the object is saved in the DataStore.
 
DataStore::EDurability getDurability () const
 Return durability with which the object is saved in the DataStore.
 
AccessorParams getAccessorParams () const
 Return pair of name and durability under which stored object is saved.
 
virtual bool operator== (const StoreAccessorBase &other) const
 Check if two store accessors point to the same object/array.
 
virtual bool operator!= (const StoreAccessorBase &other) const
 Check if two store accessors point to a different object/array.
 
TClass * getClass () const
 The underlying object's type.
 
bool isArray () const
 Is this an accessor for an array?
 
bool notWrittenOut () const
 Returns true if this object/array should not be saved by output modules.
 
std::string readableName () const
 Convert this acessor into a readable string (for messages).
 

Static Public Member Functions

static std::vector< std::string > getObjectList (DataStore::EDurability durability=DataStore::c_Event)
 Return list of object names with matching type.
 

Protected Attributes

std::string m_name
 Store name under which this object/array is saved.
 
DataStore::EDurability m_durability
 Store durability under which the object/array is saved.
 
TClass * m_class
 The underlying object's type.
 
bool m_isArray
 Is this an accessor for an array?
 

Private Member Functions

void ensureAttached () const
 Ensure that this object is attached.
 
void ensureValid () const
 if accesses to this object would crash, throw an std::runtime_error
 

Private Attributes

TObject ** m_storeObjPtr
 Store of actual pointer.
 

Detailed Description

template<class T>
class Belle2::StoreObjPtr< T >

Type-safe access to single objects in the data store.

This class provides access to single (i.e. non-array) objects in the data store, identified by their name and durability.

Accessing existing objects

This example creates a new StoreObjPtr for the EventMetaData object, using the default name (EventMetaData) and default durability (event). If no object 'EventMetaData' is found in the data store, the store object pointer is invalid (accesses to it will cause an exception).

if(!eventmetadata) {
B2INFO("an object called '" << eventmetadata.getName() << "' does not exist in the data store.");
} else {
//object exists, you can now access its data
B2INFO("we're currently in event " << eventmetadata->getEvent() << "!");
}
const std::string & getName() const
Return name under which the object is saved in the DataStore.
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96

Storing objects

First, objects have to be registered in the data store during the initialization phase, meaning in the initialize method of a module:

void MyModule::initialize() {
//register a single cdchit
//register a single cdchit under the name "AnotherHit" and do not write
//it to the output file by default
}
@ c_DontWriteOut
Object/array should be NOT saved by output modules.
Definition: DataStore.h:71
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.

Before objects can be accessed they have to be created (in each event if the durability is c_Event):

//store a single cdchit
cdchit.create(); // or construct() if you want to specify constructor arguments
cdchit->setCharge(5.0);
bool create(bool replace=false)
Create a default object in the data store.

To put an existing object in the data store, use the assign method:

//store a single cdchit
CDCHit* cdchit = new CDCHit;
cdchitPtr.assign(cdchit);
cdchitPtr->setCharge(5.0);
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
Definition: CDCHit.h:40
bool assign(TObject *object, bool replace=false)
Assign 'object' to this accessor.

Note that the datastore takes ownership of the object!

Using StoreOjbPtr as a module member variable

To avoid some overhead involved in re-creating the StoreObjPtr e.g. in each event() function call, you can also make StoreObjPtr a member variable of your class. If it is of non-event durability, you'll need to add the appropriate constructor call to the initializer list, e.g. (here with default name):

MyModule::MyModule():
m_fooPtr("", DataStore::c_Persistent)
{}
In the store you can park objects that have to be accessed by various modules.
Definition: DataStore.h:51

In initialize(), you should also use registerInDataStore() or isOptional()/isRequired() to specify wether it is an input or output. For non-default names (which you might not know in the constructor, e.g. in the case of module parameters), set the 'name' argument of any of these three functions to permanently bind the StoreObjPtr to the array with the given name.

See also
If you want to store more than a single object of one type, use the StoreArray class.
Data can also be created/accessed from Python modules using PyStoreObj

Definition at line 96 of file StoreObjPtr.h.

Constructor & Destructor Documentation

◆ StoreObjPtr()

StoreObjPtr ( const std::string &  name = "",
DataStore::EDurability  durability = DataStore::c_Event 
)
inlineexplicit

Constructor to access an object in the DataStore.

Parameters
nameName under which the object is stored in the DataStore. If an empty string is supplied, the type name will be used.
durabilityDecides durability map used for getting the accessed object.

Definition at line 104 of file StoreObjPtr.h.

104 :
105 StoreAccessorBase(DataStore::objectName<T>(name), durability, T::Class(), false), m_storeObjPtr(0) {}
StoreAccessorBase(const std::string &name, DataStore::EDurability durability, TClass *objClass, bool isArray)
Constructor to access an object or array in the DataStore.
TObject ** m_storeObjPtr
Store of actual pointer.
Definition: StoreObjPtr.h:170

Member Function Documentation

◆ assign()

bool assign ( TObject *  object,
bool  replace = false 
)
inherited

Assign 'object' to this accessor.

(takes ownership).

Parameters
objectThe object that should be put in the DataStore, should be of same type as the one used by this accessor.
replaceShould an existing object be replaced? (if existing and supplied object are equal, this has no effect)
Returns
True if the assignment succeeded. If false, assign() will delete 'object', do not use it afterwards.

Definition at line 33 of file StoreAccessorBase.cc.

34{
35 if (not object)
36 return false;
37
38 bool success = false;
39 const bool objIsArray = (object->IsA() == TClonesArray::Class());
40 TClass* objClass = objIsArray ? (static_cast<TClonesArray*>(object))->GetClass() : object->IsA();
41 if (objIsArray != isArray()) {
42 B2ERROR("Cannot assign an object to an array (or vice versa); while assigning to " << readableName());
43 } else if (objClass != getClass()) {
44 B2ERROR("Cannot assign() an object of type '" << objClass->GetName() << "' to " << readableName() << " of type '" <<
45 getClass()->GetName() << "'!");
46 } else {
47 success = DataStore::Instance().createObject(object, replace, *this);
48 }
49 if (!success)
50 delete object;
51 return success;
52}
static DataStore & Instance()
Instance of singleton Store.
Definition: DataStore.cc:54
bool createObject(TObject *object, bool replace, const StoreAccessorBase &accessor)
Create a new object/array in the DataStore or add an existing one.
Definition: DataStore.cc:316
std::string readableName() const
Convert this acessor into a readable string (for messages).
TClass * getClass() const
The underlying object's type.
bool isArray() const
Is this an accessor for an array?

◆ clear()

virtual void clear ( )
inlinevirtualinherited

Clear contents of this object.

Reimplemented in RelationArray, StoreArray< T >, StoreArray< Particle >, StoreArray< Belle2::ARICHDigit >, StoreArray< Belle2::RawFTSW >, StoreArray< Belle2::ARICHHit >, StoreArray< Belle2::ARICHTrack >, StoreArray< Belle2::ARICHLikelihood >, StoreArray< Belle2::ARICHSimHit >, StoreArray< Belle2::Track >, StoreArray< Belle2::ExtHit >, StoreArray< Belle2::MCParticle >, StoreArray< Belle2::ARICHAeroHit >, StoreArray< Belle2::ARICHInfo >, StoreArray< Belle2::AWESOMESimHit >, StoreArray< Belle2::SpacePointTrackCand >, StoreArray< Belle2::Particle >, StoreArray< Belle2::ECLCluster >, StoreArray< Belle2::KLMCluster >, StoreArray< Belle2::TrackFitResult >, StoreArray< Belle2::V0 >, StoreArray< Belle2::BelleTrkExtra >, StoreArray< Belle2::PIDLikelihood >, StoreArray< Belle2::KLMHit2d >, StoreArray< Belle2::KLMDigit >, StoreArray< Belle2::KLMDigitRaw >, StoreArray< Belle2::KLMDigitEventInfo >, StoreArray< Belle2::KLMSimHit >, StoreArray< Belle2::BKLMHit1d >, StoreArray< Belle2::BKLMTrack >, StoreArray< Belle2::RecoTrack >, StoreArray< Belle2::RecoHitInformation >, StoreArray< Belle2::CDCHit >, StoreArray< Belle2::ECLDigit >, StoreArray< Belle2::ECLDsp >, StoreArray< Belle2::PXDDigit >, StoreArray< Belle2::PXDCluster >, StoreArray< Belle2::SVDShaperDigit >, StoreArray< Belle2::SVDCluster >, StoreArray< Belle2::TOPDigit >, StoreArray< Belle2::PXDSimHit >, StoreArray< Belle2::SVDSimHit >, StoreArray< Belle2::CDCSimHit >, StoreArray< Belle2::TOPSimHit >, StoreArray< Belle2::ECLSimHit >, StoreArray< Belle2::ECLHit >, StoreArray< Belle2::BeamabortSimHit >, StoreArray< Belle2::CLAWSSimHit >, StoreArray< Belle2::ClawSimHit >, StoreArray< Belle2::FANGSSimHit >, StoreArray< Belle2::PlumeSimHit >, StoreArray< Belle2::PindiodeSimHit >, StoreArray< Belle2::He3tubeSimHit >, StoreArray< Belle2::MicrotpcSimHit >, StoreArray< Belle2::QcsmonitorSimHit >, StoreArray< Belle2::BgoSimHit >, StoreArray< Belle2::CsiSimHit >, StoreArray< Belle2::Btube >, StoreArray< Belle2::RawCDC >, StoreArray< Belle2::CDCRawHit >, StoreArray< Belle2::CDCRawHitWaveForm >, StoreArray< Belle2::ECLShower >, StoreArray< Belle2::CDCDedxTrack >, StoreArray< Belle2::CDCDedxLikelihood >, StoreArray< Belle2::CDCTriggerSegmentHit >, StoreArray< Belle2::CDCTriggerTrack >, StoreArray< Belle2::CDCTriggerHoughCluster >, StoreArray< Belle2::CDCTrigger3DFinderInfo >, StoreArray< Belle2::CDCTriggerMLPInput >, StoreArray< Belle2::Bitstream >, StoreArray< Belle2::RawTRG >, StoreArray< Bitstream< MergerBus > >, StoreArray< Belle2::CDCTriggerFinderClone >, StoreArray< Belle2::Cluster >, StoreArray< Belle2::ContinuumSuppression >, StoreArray< Belle2::RawDataBlock >, StoreArray< Belle2::RawCOPPER >, StoreArray< Belle2::RawSVD >, StoreArray< Belle2::RawTOP >, StoreArray< Belle2::RawARICH >, StoreArray< Belle2::RawECL >, StoreArray< Belle2::RawKLM >, StoreArray< genfit::Track >, StoreArray< Belle2::CsiHit >, StoreArray< Belle2::CsiDigiHit >, StoreArray< Belle2::RawPXD >, StoreArray< Belle2::ECLCalDigit >, StoreArray< Belle2::BeamBackHit >, StoreArray< Belle2::ECLTrig >, StoreArray< Belle2::TRGECLWaveform >, StoreArray< Belle2::ECLConnectedRegion >, StoreArray< Belle2::ECLPidLikelihood >, StoreArray< Belle2::ECLLocalMaximum >, StoreArray< Belle2::ECLPureCsIInfo >, StoreArray< Belle2::ECLDspWithExtraMCInfo >, StoreArray< Belle2::KlId >, StoreArray< Belle2::ECLDebugHit >, StoreArray< Belle2::TRGECLUnpackerStore >, StoreArray< Belle2::TRGECLUnpackerEvtStore >, StoreArray< Belle2::ECLTriggerCell >, StoreArray< Belle2::BremHit >, StoreArray< Belle2::ECLEnergyCloseToTrack >, StoreArray< Belle2::TRGECLCluster >, StoreArray< Belle2::RestOfEvent >, StoreArray< Belle2::FlavorTaggerInfo >, StoreArray< Belle2::FlavorTaggerInfoMap >, StoreArray< Belle2::TRGGDLUnpackerStore >, StoreArray< Belle2::SpacePoint >, StoreArray< genfit::TrackCand >, StoreArray< Belle2::PXDTrueHit >, StoreArray< Belle2::SVDTrueHit >, StoreArray< Belle2::ROIid >, StoreArray< Belle2::KLMClusterShape >, StoreArray< Belle2::KLMScintillatorFirmwareFitResult >, StoreArray< Belle2::KLMMuonIDDNNInputVariable >, StoreArray< Belle2::EKLMAlignmentHit >, StoreArray< Belle2::Kink >, StoreArray< Belle2::TRGECLDigi0MC >, StoreArray< Belle2::TRGECLHitMC >, StoreArray< Belle2::TOPLikelihood >, StoreArray< Belle2::VXDDedxLikelihood >, StoreArray< Belle2::KLMMuidLikelihood >, StoreArray< NNBitStream >, StoreArray< Belle2::V0ValidationVertex >, StoreArray< Belle2::ObserverInfo >, StoreArray< Belle2::OnlineEventT0 >, StoreArray< Belle2::TOPSimCalPulse >, StoreArray< Belle2::PXDRawHit >, StoreArray< Belle2::PXDRawROIs >, StoreArray< Belle2::PXDRawAdc >, StoreArray< Belle2::PXDIntercept >, StoreArray< Belle2::PXD2TrackEvent >, StoreArray< Belle2::StringWrapper >, StoreArray< Belle2::HE3G4TrackInfo >, StoreArray< Belle2::TPCG4TrackInfo >, StoreArray< Belle2::SADMetaHit >, StoreArray< Belle2::SVDRecoDigit >, StoreArray< Belle2::SVDDAQDiagnostic >, StoreArray< Belle2::SVDIntercept >, StoreArray< StoredClass >, StoreArray< Belle2::MCParticleTrajectory >, StoreArray< TObject >, StoreArray< Belle2::TOPBarHit >, StoreArray< Belle2::TOPSimPhoton >, StoreArray< Belle2::TOPRawDigit >, StoreArray< Belle2::TOPTimeZero >, StoreArray< Belle2::TOPRawWaveform >, StoreArray< Belle2::TOPLikelihoodScanResult >, StoreArray< Belle2::TOPPDFCollection >, StoreArray< Belle2::TOPAssociatedPDF >, StoreArray< Belle2::TOPPixelLikelihood >, StoreArray< Belle2::TOPProductionEventDebug >, StoreArray< Belle2::TOPPull >, StoreArray< Belle2::TOPSlowData >, StoreArray< Belle2::TOPInterimFEInfo >, StoreArray< Belle2::TOPProductionHitDebug >, StoreArray< Belle2::TOPTemplateFitResult >, StoreArray< Belle2::TRGCDCETFUnpackerStore >, StoreArray< Belle2::TRGCDCT3DUnpackerStore >, StoreArray< Belle2::TRGCDCTSFUnpackerStore >, StoreArray< Belle2::TRGECLBGTCHit >, StoreArray< Belle2::TRGECLUnpackerSumStore >, StoreArray< Belle2::TRGECLDigi0 >, StoreArray< Belle2::TRGECLHit >, StoreArray< Belle2::TRGECLFAMAna >, StoreArray< Belle2::TRGECLTrg >, StoreArray< Belle2::TRGECLTiming >, StoreArray< Belle2::TRGTOPTimeStampsSlot >, StoreArray< Belle2::TRGTOPTimeStamp >, StoreArray< Belle2::TRGTOPCombinedT0Decision >, StoreArray< Belle2::TRGTOPSlotTiming >, StoreArray< Belle2::TRGTOPWaveFormTimeStampsSlot >, StoreArray< Belle2::TRGTOPWaveFormTimeStamp >, StoreArray< Belle2::TagVertex >, StoreArray< Belle2::KLMMuidHit >, StoreArray< Belle2::TrackClusterSeparation >, StoreArray< Belle2::OverlapNetwork >, StoreArray< TSFOutputBitStream >, StoreArray< T2DOutputBitStream >, StoreArray< SimHitClass >, StoreArray< TrueHitClass >, StoreArray< Belle2::VXDDedxTrack >, StoreArray< Belle2::BeamabortHit >, StoreArray< Belle2::BgoHit >, StoreArray< Belle2::ClawHit >, StoreArray< Belle2::ClawsHit >, StoreArray< Belle2::CsiHit_v2 >, StoreArray< Belle2::DosiHit >, StoreArray< Belle2::FANGSHit >, StoreArray< Belle2::He3tubeHit >, StoreArray< Belle2::MicrotpcHit >, StoreArray< Belle2::PindiodeHit >, StoreArray< Belle2::PlumeHit >, StoreArray< Belle2::QcsmonitorHit >, StoreArray< CDCTriggerSegmentHit >, StoreArray< CDCTriggerTrack >, StoreArray< CDCTriggerMLPInput >, StoreArray< RecoTrack >, StoreArray< SpacePoint >, StoreArray< PXDCluster >, StoreArray< SpacePointTrackCand >, StoreArray< DirectedNodeNetworkContainer >, StoreArray< SVDCluster >, and StoreArray< MCParticle >.

Definition at line 121 of file StoreAccessorBase.h.

122 {
123 create(true);
124 }

◆ construct()

bool construct ( Args &&...  params)
inline

Construct an object of type T in this StoreObjPtr, using the provided constructor arguments.

If this StoreObjPtr already contains an object, this function will fail.

Returns
True if the creation succeeded.

Definition at line 119 of file StoreObjPtr.h.

120 {
121 T* t = new T(std::forward<Args>(params)...);
122 return assign(t, false);
123 }

◆ constructAndReplace()

bool constructAndReplace ( Args &&...  params)
inline

Construct an object of type T in this StoreObjPtr, using the provided constructor arguments.

If this StoreObjPtr already contains an object, it will be replaced.

Returns
True if the creation succeeded.

Definition at line 131 of file StoreObjPtr.h.

132 {
133 T* t = new T(std::forward<Args>(params)...);
134 return assign(t, true);
135 }

◆ create()

bool create ( bool  replace = false)
inlineinherited

Create a default object in the data store.

This only works after registerInDataStore() has been called by this or another module.

Parameters
replaceShould an existing object be replaced?
Returns
True if the creation succeeded.

Definition at line 107 of file StoreAccessorBase.h.

108 {
109 return DataStore::Instance().createObject(0, replace, *this);
110 }

◆ ensureAttached()

void ensureAttached ( ) const
inlineprivate

Ensure that this object is attached.

Definition at line 155 of file StoreObjPtr.h.

156 {
157 if (!m_storeObjPtr) {
158 const_cast<StoreObjPtr*>(this)->m_storeObjPtr = DataStore::Instance().getObject(*this);
159 }
160 }
TObject ** getObject(const StoreAccessorBase &accessor)
Get a pointer to a pointer of an object in the DataStore.
Definition: DataStore.cc:306
StoreObjPtr(const std::string &name="", DataStore::EDurability durability=DataStore::c_Event)
Constructor to access an object in the DataStore.
Definition: StoreObjPtr.h:104

◆ ensureValid()

void ensureValid ( ) const
inlineprivate

if accesses to this object would crash, throw an std::runtime_error

Definition at line 162 of file StoreObjPtr.h.

163 {
165 if (!m_storeObjPtr || !(*m_storeObjPtr))
166 throw std::runtime_error("Trying to access StoreObjPtr " + readableName() +
167 ", which was not created. Please check isValid() before accesses if the object is not guaranteed to be created in every event.");
168 }
void ensureAttached() const
Ensure that this object is attached.
Definition: StoreObjPtr.h:155

◆ getAccessorParams()

AccessorParams getAccessorParams ( ) const
inlineinherited

Return pair of name and durability under which stored object is saved.


Definition at line 134 of file StoreAccessorBase.h.

134{ return make_pair(m_name, m_durability);}
DataStore::EDurability m_durability
Store durability under which the object/array is saved.
std::string m_name
Store name under which this object/array is saved.

◆ getClass()

TClass * getClass ( ) const
inlineinherited

The underlying object's type.

Definition at line 149 of file StoreAccessorBase.h.

149{ return m_class; }
TClass * m_class
The underlying object's type.

◆ getDurability()

DataStore::EDurability getDurability ( ) const
inlineinherited

Return durability with which the object is saved in the DataStore.

Definition at line 131 of file StoreAccessorBase.h.

131{ return m_durability; }

◆ getName()

const std::string & getName ( ) const
inlineinherited

Return name under which the object is saved in the DataStore.

Definition at line 128 of file StoreAccessorBase.h.

128{ return m_name; }

◆ getObjectList()

static std::vector< std::string > getObjectList ( DataStore::EDurability  durability = DataStore::c_Event)
inlinestatic

Return list of object names with matching type.


Definition at line 148 of file StoreObjPtr.h.

149 {
150 return DataStore::Instance().getListOfObjects(T::Class(), durability);
151 }
std::vector< std::string > getListOfObjects(const TClass *objClass, EDurability durability) const
Returns a list of names of StoreObjPtr-objects whose class is (or inherits from) objClass.
Definition: DataStore.cc:671

◆ isArray()

bool isArray ( ) const
inlineinherited

Is this an accessor for an array?

Definition at line 152 of file StoreAccessorBase.h.

152{ return m_isArray; }
bool m_isArray
Is this an accessor for an array?

◆ isOptional()

bool isOptional ( const std::string &  name = "")
inlineinherited

Tell the DataStore about an optional input.

Mainly useful for creating diagrams of module inputs and outputs.

Parameters
nameIf not empty, set non-default name for this object/array. This is permanent, so that e.g. after using registerInDataStore("myName") in initialize(), this object will continue refer to 'myName' in event().
Returns
True if the object/array exists.

Definition at line 93 of file StoreAccessorBase.h.

94 {
95 if (!name.empty())
96 m_name = name;
97 return DataStore::Instance().optionalInput(*this);
98 }
bool optionalInput(const StoreAccessorBase &accessor)
Register the given object/array as an optional input.
Definition: DataStore.cc:739

◆ isRequired()

bool isRequired ( const std::string &  name = "")
inlineinherited

Ensure this array/object has been registered previously.

Will cause an ERROR if it does not exist. This must be called in the initialization phase.

Parameters
nameIf not empty, set non-default name for this object/array. This is permanent, so that e.g. after using registerInDataStore("myName") in initialize(), this object will continue refer to 'myName' in event().
Returns
True if the object/array exists.

Definition at line 78 of file StoreAccessorBase.h.

79 {
80 if (!name.empty())
81 m_name = name;
82 return DataStore::Instance().requireInput(*this);
83 }
bool requireInput(const StoreAccessorBase &accessor)
Produce ERROR message if no entry of the given type is registered in the DataStore.
Definition: DataStore.cc:722

◆ isValid()

bool isValid ( ) const
inline

Check whether the object was created.

Returns
True if the object exists.

Definition at line 111 of file StoreObjPtr.h.

◆ notWrittenOut()

bool notWrittenOut ( ) const
inherited

Returns true if this object/array should not be saved by output modules.

See DataStore::c_DontWriteOut. Can be changed by re-registering it with/without the flag.

Definition at line 53 of file StoreAccessorBase.cc.

54{
56 if (!entry) {
57 B2ERROR("notWrittenOut(): " << readableName() << " doesn't seem to be registered");
58 return false;
59 }
60 return entry->dontWriteOut;
61}
StoreEntry * getEntry(const StoreAccessorBase &accessor)
Check whether an entry with the correct type is registered in the DataStore map and return it.
Definition: DataStore.cc:294
Wraps a stored array/object, stored under unique (name, durability) key.
Definition: StoreEntry.h:22
bool dontWriteOut
Flag that indicates whether the object should be written to the output by default.
Definition: StoreEntry.h:40

◆ operator bool()

operator bool ( ) const
inline

Imitate pointer functionality.

Definition at line 144 of file StoreObjPtr.h.

◆ operator!=()

virtual bool operator!= ( const StoreAccessorBase other) const
inlinevirtualinherited

Check if two store accessors point to a different object/array.

Definition at line 143 of file StoreAccessorBase.h.

144 {
145 return !(*this == other);
146 }

◆ operator*()

T & operator* ( ) const
inline

Imitate pointer functionality.

Definition at line 138 of file StoreObjPtr.h.

◆ operator->()

T * operator-> ( ) const
inline

Imitate pointer functionality.

Definition at line 142 of file StoreObjPtr.h.

◆ operator==()

virtual bool operator== ( const StoreAccessorBase other) const
inlinevirtualinherited

Check if two store accessors point to the same object/array.

Definition at line 137 of file StoreAccessorBase.h.

138 {
139 return getAccessorParams() == other.getAccessorParams();
140 }
AccessorParams getAccessorParams() const
Return pair of name and durability under which stored object is saved.

◆ readableName()

std::string readableName ( ) const
inherited

Convert this acessor into a readable string (for messages).

e.g. "object EventMetaData (durability: event)"

Definition at line 18 of file StoreAccessorBase.cc.

19{
20 std::string str(isArray() ? "array" : "object");
21 str += " '" + getName() + "' (durability: ";
22 switch (getDurability()) {
24 str += "event";
25 break;
27 str += "persistent";
28 break;
29 }
30 return str + ")";
31}
@ c_Persistent
Object is available during entire execution time.
Definition: DataStore.h:60
@ c_Event
Different object in each event, all objects/arrays are invalidated after event() function has been ca...
Definition: DataStore.h:59
DataStore::EDurability getDurability() const
Return durability with which the object is saved in the DataStore.

◆ registerInDataStore() [1/2]

bool registerInDataStore ( const std::string &  name,
DataStore::EStoreFlags  storeFlags = DataStore::c_WriteOut 
)
inlineinherited

Register the object/array in the DataStore.

This must be called in the initialization phase.

Parameters
nameIf not empty, set non-default name for this object/array. This is permanent, so that e.g. after using registerInDataStore("myName") in initialize(), this object will continue refer to 'myName' in event().
storeFlagsORed combination of DataStore::EStoreFlags.
Returns
True if the registration succeeded.

Definition at line 64 of file StoreAccessorBase.h.

65 {
66 if (!name.empty())
67 m_name = name;
69 }
bool registerEntry(const std::string &name, EDurability durability, TClass *objClass, bool array, EStoreFlags storeFlags)
Register an entry in the DataStore map.
Definition: DataStore.cc:190

◆ registerInDataStore() [2/2]

bool registerInDataStore ( DataStore::EStoreFlags  storeFlags = DataStore::c_WriteOut)
inlineinherited

Register the object/array in the DataStore.

This must be called in the initialization phase.

Parameters
storeFlagsORed combination of DataStore::EStoreFlags.
Returns
True if the registration succeeded.

Definition at line 52 of file StoreAccessorBase.h.

53 {
55 }

Member Data Documentation

◆ m_class

TClass* m_class
protectedinherited

The underlying object's type.

Definition at line 172 of file StoreAccessorBase.h.

◆ m_durability

DataStore::EDurability m_durability
protectedinherited

Store durability under which the object/array is saved.

Definition at line 169 of file StoreAccessorBase.h.

◆ m_isArray

bool m_isArray
protectedinherited

Is this an accessor for an array?

Definition at line 175 of file StoreAccessorBase.h.

◆ m_name

std::string m_name
protectedinherited

Store name under which this object/array is saved.

Definition at line 166 of file StoreAccessorBase.h.

◆ m_storeObjPtr

TObject** m_storeObjPtr
private

Store of actual pointer.

Don't make this a T** as this might cause problems with multiple inheritance objects

Definition at line 170 of file StoreObjPtr.h.


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