| The Gaudi Framework v30r0 (c919700c)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

KeyedObject.cpp
Go to the documentation of this file.
1 // Include files
2 #include "GaudiKernel/ContainedObject.h"
3 #include "GaudiKernel/GaudiException.h"
4 #include "GaudiKernel/IDataProviderSvc.h"
5 #include "GaudiKernel/IRegistry.h"
6 #include "GaudiKernel/Kernel.h"
7 #include "GaudiKernel/LinkManager.h"
8 #include "GaudiKernel/ObjectContainerBase.h"
9
15 namespace Objects
16 {
17 bool access( const ContainedObject* from, ContainedObject** to );
18 bool access( const DataObject* from, DataObject** to );
19
20 template <class TO, class FROM>
21 TO* reference( FROM* from )
22 {
23 ContainedObject* to = nullptr;
24 return access( from, &to ) ? dynamic_cast<TO*>( to ) : nullptr;
25 }
26 }
27
28 bool Objects::access( const DataObject* from, DataObject** to )
29 {
30 DataObject* src = const_cast<DataObject*>( from );
31 DataObject* tar = nullptr;
32 if ( src ) {
33 LinkManager* mgr = src->linkMgr();
34 if ( mgr ) {
35 LinkManager::Link* link = mgr->link( long( 0 ) );
36 if ( link ) {
37 tar = link->object();
38 if ( !tar ) {
39 IRegistry* reg = src->registry();
40 if ( reg ) {
41 IDataProviderSvc* ds = reg->dataSvc();
42 if ( ds && ds->retrieveObject( link->path(), tar ).isSuccess() ) {
43 link->setObject( tar );
44 }
45 }
46 }
47 }
48 }
49 }
50 *to = tar;
51 return tar != nullptr;
52 }
53
54 // Load on demand: ContainedObject type references
55 bool Objects::access( const ContainedObject* from, ContainedObject** to )
56 {
57 *to = nullptr;
58 if ( from ) {
59 DataObject* tar = nullptr;
60 if ( access( from->parent(), &tar ) ) {
61 ObjectContainerBase* cnt = dynamic_cast<ObjectContainerBase*>( tar );
62 if ( cnt ) {
63 *to = cnt->containedObject( from->index() );
64 }
65 }
66 }
67 return *to != nullptr;
68 }
Objects
Namespace for basic object handling within container classes.
Definition: KeyedObject.cpp:15
LinkManager::Link::path
const std::string & path() const
Access to path of object.
Definition: LinkManager.h:66
Kernel.h
LinkManager.h
ContainedObject::index
virtual long index() const
Distance in the parent container.
Definition: ContainedObject.h:57
ObjectContainerBase.h
IDataProviderSvc
Data provider interface definition.
Definition: IDataProviderSvc.h:46
ContainedObject::parent
const ObjectContainerBase * parent() const
Access to parent object.
Definition: ContainedObject.h:52
DataObject::registry
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:73
DataObject::linkMgr
LinkManager * linkMgr() const
Retrieve Link manager.
Definition: DataObject.h:75
ObjectContainerBase::containedObject
virtual ContainedObject * containedObject(long dist) const =0
Pointer to an object of a given distance.
IDataProviderSvc.h
LinkManager::Link::setObject
void setObject(const DataObject *pObject)
Update object pointer.
Definition: LinkManager.h:61
GaudiException.h
LinkManager::link
Link * link(long id)
Retrieve symbolic link identified by ID.
Definition: LinkManager.cpp:31
IRegistry::dataSvc
virtual IDataProviderSvc * dataSvc() const =0
Retrieve pointer to Transient Store.
IRegistry.h
IRegistry
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
Objects::access
bool access(const ContainedObject *from, ContainedObject **to)
Definition: KeyedObject.cpp:55
IDataProviderSvc::retrieveObject
virtual StatusCode retrieveObject(IRegistry *pDirectory, boost::string_ref path, DataObject *&pObject)=0
Retrieve object identified by its directory entry.
ContainedObject
All classes that their objects may be contained in an LHCb ObjectContainer (e.g.
Definition: ContainedObject.h:31
ContainedObject.h
ObjectContainerBase
ObjectContainerBase is the base class for Gaudi container classes.
Definition: ObjectContainerBase.h:19
LinkManager::Link::object
const DataObject * object() const
Const access to data object.
Definition: LinkManager.h:63
LinkManager::Link
Embedded class defining a symbolic link Note: No copy constructor; bitwise copy (done by the compiler...
Definition: LinkManager.h:32
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
LinkManager
A LinkManager is the object aggregated into a DataObject, which is responsible for the handling of no...
Definition: LinkManager.h:21
Objects::reference
TO * reference(FROM *from)
Definition: KeyedObject.cpp:21