| The Gaudi Framework v29r1 (5cd95fa2)

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

- File List
- File Members

LinkManager.cpp
Go to the documentation of this file.
1 // Experiment specific include files
2 #include "GaudiKernel/LinkManager.h"
3 #include "GaudiKernel/DataObject.h"
4 #include "GaudiKernel/IRegistry.h"
5
6 static LinkManager* ( *s_newInstance )() = nullptr;
7
9 LinkManager::~LinkManager()
10 {
11 for ( auto& i : m_linkVector ) delete i;
12 }
13
15 IOpaqueAddress* LinkManager::Link::address()
16 {
17 if ( m_pObject ) {
18 IRegistry* pReg = m_pObject->registry();
19 if ( pReg ) return pReg->address();
20 }
21 return nullptr;
22 }
23
25 void LinkManager::setInstantiator( LinkManager* ( *newInstance )() ) { s_newInstance = newInstance; }
26
28 LinkManager* LinkManager::newInstance() { return s_newInstance ? ( *s_newInstance )() : new LinkManager(); }
29
31 LinkManager::Link* LinkManager::link( long id )
32 {
33 return ( 0 <= id && (unsigned)id < m_linkVector.size() ) ? m_linkVector[id] : nullptr;
34 }
35
37 LinkManager::Link* LinkManager::link( const DataObject* pObject )
38 {
39 if ( pObject ) {
40 for ( auto& i : m_linkVector ) {
41 if ( i->object() == pObject ) return i;
42 }
43 }
44 return nullptr;
45 }
46
48 LinkManager::Link* LinkManager::link( const std::string& path )
49 {
50 if ( 0 != path.length() ) {
51 for ( auto& i : m_linkVector ) {
52 if ( i->path() == path ) return i;
53 }
54 }
55 return nullptr;
56 }
57
59 long LinkManager::addLink( const std::string& path, const DataObject* pObject ) const
60 {
61 long n = 0;
62 for ( auto& lnk : m_linkVector ) {
63 const DataObject* pO = lnk->object();
64 if ( pO && pO == pObject ) return n;
65 if ( lnk->path() == path ) {
66 if ( pObject && pObject != pO ) {
67 lnk->setObject( const_cast<DataObject*>( pObject ) );
68 }
69 return n;
70 }
71 ++n;
72 }
73 // Link is completely unknown
74 m_linkVector.emplace_back( new Link( m_linkVector.size(), path, const_cast<DataObject*>( pObject ) ) );
75 return m_linkVector.back()->ID();
76 }
77
78 // Remove a link by object reference
79 long LinkManager::removeLink( const DataObject* pObject ) const
80 {
81 long n = 0;
82 for ( auto i = m_linkVector.begin(); i != m_linkVector.end(); i++ ) {
83 if ( ( *i )->object() == pObject ) {
84 delete *i;
85 m_linkVector.erase( i );
86 return n;
87 }
88 ++n;
89 }
90 return INVALID;
91 }
92
93 // Remove a link by object reference
94 long LinkManager::removeLink( const std::string& path ) const
95 {
96 long n = 0;
97 for ( auto i = m_linkVector.begin(); i != m_linkVector.end(); i++ ) {
98 if ( ( *i )->path() == path ) {
99 delete *i;
100 m_linkVector.erase( i );
101 return n;
102 }
103 n++;
104 }
105 return INVALID;
106 }
107
108 // Remove a link by object reference
109 long LinkManager::removeLink( long id ) const
110 {
111 auto i = std::next( m_linkVector.begin(), id );
112 delete *i;
113 m_linkVector.erase( i );
114 return id;
115 }
116
118 void LinkManager::clearLinks()
119 {
120 for ( auto& i : m_linkVector ) delete i;
121 m_linkVector.clear();
122 }
LinkManager.h
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:895
LinkManager::addLink
long addLink(const std::string &path, const DataObject *pObject) const
Add link by object reference and path.
Definition: LinkManager.cpp:59
std::string
STL class.
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:228
LinkManager::setInstantiator
static void setInstantiator(LinkManager *(*newInstance)())
Assign new instantiator.
Definition: LinkManager.cpp:25
LinkManager::Link::address
IOpaqueAddress * address()
Access to the object&#39;s address.
Definition: LinkManager.cpp:15
LinkManager::m_linkVector
std::vector< Link * > m_linkVector
@ TODO: replace by std::vector<std::unique_ptr<Link>> once ROOT does &#39;automatic&#39; schema conversion fr...
Definition: LinkManager.h:93
std::next
T next(T...args)
LinkManager::clearLinks
void clearLinks()
Remove all possibly existing symbolic links.
Definition: LinkManager.cpp:118
LinkManager::link
Link * link(long id)
Retrieve symbolic link identified by ID.
Definition: LinkManager.cpp:31
LinkManager::newInstance
static LinkManager * newInstance()
Static instantiation.
Definition: LinkManager.cpp:28
IRegistry.h
IRegistry
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
LinkManager::LinkManager
LinkManager()=default
Standard Constructor.
LinkManager::INVALID
Definition: LinkManager.h:26
LinkManager::removeLink
long removeLink(const DataObject *pObject) const
Remove link by object reference.
Definition: LinkManager.cpp:79
std::string::length
T length(T...args)
LinkManager::Link
Embedded class defining a symbolic link Note: No copy constructor; bitwise copy (done by the compiler...
Definition: LinkManager.h:32
IOpaqueAddress
Opaque address interface definition.
Definition: IOpaqueAddress.h:23
IRegistry::address
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:29
LinkManager
A LinkManager is the object aggregated into a DataObject, which is responsible for the handling of no...
Definition: LinkManager.h:21
LinkManager::~LinkManager
virtual ~LinkManager()
Standard Destructor.
Definition: LinkManager.cpp:9
DataObject.h