 |
Belle II Software
release-05-02-19
|
13 #include <framework/datastore/DataStore.h>
14 #include <framework/datastore/RelationVector.h>
15 #include <framework/datastore/RelationEntry.h>
29 namespace _RelationsInterfaceImpl {
104 static_assert(std::is_same<TObject, BASE>::value,
105 "Using RelationsInterface<BASE> is no longer allowed. Please use RelationsObject as a base class.");
113 BASE(std::forward<Args>(params)...),
122 BASE(relationsInterface),
132 if (
this != &relationsInterface)
133 this->BASE::operator=(relationsInterface);
157 void addRelationTo(
const TObject*
object,
float weight = 1.0,
const std::string& namedRelation =
"")
const
177 for (
unsigned int iRel = 0; iRel < fromRels.size(); iRel++) {
178 fromRels.object(iRel)->
addRelationTo(
this, fromRels.weight(iRel));
182 for (
unsigned int iRel = 0; iRel < toRels.size(); iRel++) {
183 this->
addRelationTo(toRels.object(iRel), toRels.weight(iRel));
215 const std::string& namedRelation =
"")
const
250 template <
class TO> TO*
getRelatedTo(
const std::string& name =
"",
const std::string& namedRelation =
"")
const
253 TO::Class(), name, namedRelation).
object);
265 template <
class FROM> FROM*
getRelatedFrom(
const std::string& name =
"",
const std::string& namedRelation =
"")
const
280 template <
class T> T*
getRelated(
const std::string& name =
"",
const std::string& namedRelation =
"")
const
283 T::Class(), name, namedRelation).
object);
300 const std::string& namedRelation =
"")
const
303 TO::Class(), name, namedRelation);
304 return std::make_pair(
static_cast<TO*
>(entry.
object), entry.
weight);
317 const std::string& namedRelation =
"")
const
320 FROM::Class(), name, namedRelation);
321 return std::make_pair(
static_cast<FROM*
>(entry.
object), entry.
weight);
334 const std::string& namedRelation =
"")
const
337 T::Class(), name, namedRelation);
338 return std::make_pair(
static_cast<T*
>(entry.
object), entry.
weight);
346 virtual std::string
getName()
const {
return ""; }
394 #if defined(__CINT__) || defined(__ROOTCLING__) || defined(R__DICTIONARY_FILENAME)
402 return getRelationsTo<TObject>(name);
406 return getRelationsFrom<TObject>(name);
410 return getRelationsWith<TObject>(name);
412 TObject*
getRelatedTo(
const std::string& name,
const std::string& namedRelation =
"")
const {
return getRelatedTo<TObject>(name, namedRelation); }
413 TObject*
getRelatedFrom(
const std::string& name,
const std::string& namedRelation =
"")
const {
return getRelatedFrom<TObject>(name, namedRelation); }
414 TObject*
getRelated(
const std::string& name,
const std::string& namedRelation =
"")
const {
return getRelated<TObject>(name, namedRelation); }
@ c_BothSides
Combination of c_FromSide and c_ToSide.
DataStore::StoreEntry * m_cacheDataStoreEntry
Cache of the data store entry to which this object belongs.
std::pair< T *, float > getRelatedWithWeight(const std::string &name="", const std::string &namedRelation="") const
Get first related object & weight of relation pointing from/to an array.
TClonesArray * getArrayPointer() const
Returns the pointer to the raw DataStore array holding this object (protected since these arrays are ...
RelationVector< T > getRelationsWith(const std::string &name="", const std::string &namedRelation="") const
Get the relations between this object and another store array.
std::string getInfo() const
Return a short summary of this object's contents in raw text format.
static DataStore & Instance()
Instance of singleton Store.
RelationsInterface & operator=(const RelationsInterface &relationsInterface)
Assignment operator.
RelationsInterface(Args &&... params)
Constructor, forwards all arguments to BASE constructor.
void addRelation(const TObject *fromObject, StoreEntry *&fromEntry, int &fromIndex, const TObject *toObject, StoreEntry *&toEntry, int &toIndex, float weight, const std::string &namedRelation)
Add a relation from an object in a store array to another object in a store array.
Wraps a stored array/object, stored under unique (name, durability) key.
ClassDef(RelationsInterface, 0)
defines interface for accessing relations of objects in StoreArray.
std::string getArrayName() const
Get name of array this object is stored in, or "" if not found.
void addRelationTo(const RelationsInterface< BASE > *object, float weight=1.0, const std::string &namedRelation="") const
Add a relation from this object to another object (with caching).
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.
TO * getRelatedTo(const std::string &name="", const std::string &namedRelation="") const
Get the object to which this object has a relation.
float weight
Weight of the relation.
RelationsInterface(const RelationsInterface &relationsInterface)
Copy constructor.
RelationVector< TO > getRelationsTo(const std::string &name="", const std::string &namedRelation="") const
Get the relations that point from this object to another store array.
std::string name
Name of the entry.
std::pair< TO *, float > getRelatedToWithWeight(const std::string &name="", const std::string &namedRelation="") const
Get first related object & weight of relation pointing to an array.
Class for type safe access to objects that are referred to in relations.
TObject * object
Pointer to the object.
Abstract base class for different kinds of events.
virtual std::string getName() const
Return a short name that describes this object, e.g.
std::pair< FROM *, float > getRelatedFromWithWeight(const std::string &name="", const std::string &namedRelation="") const
Get first related object & weight of relation pointing from an array.
RelationVector< FROM > getRelationsFrom(const std::string &name="", const std::string &namedRelation="") const
Get the relations that point from another store array to this object.
@ c_ToSide
Return relations/objects pointed to (from a given object).
void copyRelations(const RelationsInterface< BASE > *sourceObj)
Copies all relations of sourceObj (pointing from or to sourceObj) to this object (including weights).
void addRelationTo(const TObject *object, float weight=1.0, const std::string &namedRelation="") const
Add a relation from this object to another object (no caching, can be quite slow).
int m_cacheArrayIndex
Cache of the index in the TClonesArray to which this object belongs.
int getArrayIndex() const
Returns this object's array index (in StoreArray), or -1 if not found.
bool findStoreEntry(const TObject *object, StoreEntry *&entry, int &index)
Find an object in an array in the data store.
TClonesArray * getPtrAsArray() const
Return ptr cast to TClonesArray.
RelationsInterface< TObject > RelationsObject
Provides interface for getting/adding relations to objects in StoreArrays.
virtual std::string getInfoHTML() const
Return a short summary of this object's contents in HTML format.
Belle2::RelationEntry getRelationWith(ESearchSide searchSide, const TObject *object, StoreEntry *&entry, int &index, const TClass *withClass, const std::string &withName, const std::string &namedRelation)
Get the first relation between an object and another object in a store array.
In the store you can park objects that have to be accessed by various modules.
Defines interface for accessing relations of objects in StoreArray.
std::string htmlToPlainText(const std::string &html)
See RelationsObject::getInfo()
FROM * getRelatedFrom(const std::string &name="", const std::string &namedRelation="") const
Get the object from which this object has a relation.
@ c_FromSide
Return relations/objects pointed from (to a given object).
RelationsInterface()
template class cannot be removed without breaking ROOT I/O, so just disable it.