| The Gaudi Framework v27r1

- 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 for (auto& i : m_linkVector) delete i;
11 }
12
14 IOpaqueAddress* LinkManager::Link::address() {
15 if ( m_pObject ) {
16 IRegistry* pReg = m_pObject->registry();
17 if ( pReg ) return pReg->address();
18 }
19 return nullptr;
20 }
21
23 void LinkManager::setInstantiator( LinkManager* (*newInstance)() ) {
24 s_newInstance = newInstance;
25 }
26
28 LinkManager* LinkManager::newInstance() {
29 return s_newInstance ? (*s_newInstance)() : new LinkManager();
30 }
31
33 LinkManager::Link* LinkManager::link(long id) {
34 return (0<=id && (unsigned)id < m_linkVector.size()) ? m_linkVector[id] : nullptr;
35 }
36
38 LinkManager::Link* LinkManager::link(const DataObject* pObject) {
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 if ( 0 != path.length() ) {
50 for ( auto & i : m_linkVector ) {
51 if ( i->path() == path ) return i;
52 }
53 }
54 return nullptr;
55 }
56
58 long LinkManager::addLink(const std::string& path, const DataObject* pObject) const {
59 long n = 0;
60 for ( auto& lnk : m_linkVector ) {
61 const DataObject* pO = lnk->object();
62 if ( pO && pO == pObject ) return n;
63 if ( lnk->path() == path ) {
64 if ( pObject && pObject != pO ) {
65 lnk->setObject(const_cast<DataObject*>(pObject));
66 }
67 return n;
68 }
69 ++n;
70 }
71 // Link is completely unknown
72 m_linkVector.emplace_back( new Link(m_linkVector.size(), path, const_cast<DataObject*>(pObject)) );
73 return m_linkVector.back()->ID();
74 }
75
76 // Remove a link by object reference
77 long LinkManager::removeLink(const DataObject* pObject) const {
78 long n = 0;
79 for ( auto i = m_linkVector.begin(); i != m_linkVector.end(); i++ ) {
80 if ( (*i)->object() == pObject ) {
81 delete *i;
82 m_linkVector.erase(i);
83 return n;
84 }
85 ++n;
86 }
87 return INVALID;
88 }
89
90 // Remove a link by object reference
91 long LinkManager::removeLink(const std::string& path) const {
92 long n = 0;
93 for ( auto i = m_linkVector.begin(); i != m_linkVector.end(); i++ ) {
94 if ( (*i)->path() == path ) {
95 delete *i;
96 m_linkVector.erase(i);
97 return n;
98 }
99 n++;
100 }
101 return INVALID;
102 }
103
104 // Remove a link by object reference
105 long LinkManager::removeLink(long id) const {
106 auto i = std::next(m_linkVector.begin(), id );
107 delete *i;
108 m_linkVector.erase(i);
109 return id;
110 }
111
113 void LinkManager::clearLinks() {
114 for (auto& i : m_linkVector) delete i;
115 m_linkVector.clear();
116 }
LinkManager.h
LinkManager::addLink
long addLink(const std::string &path, const DataObject *pObject) const
Add link by object reference and path.
Definition: LinkManager.cpp:58
GaudiPluginService.cpluginsvc.n
list n
Definition: cpluginsvc.py:217
DataObject::registry
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:74
std::string
STL class.
LinkManager::setInstantiator
static void setInstantiator(LinkManager *(*newInstance)())
Assign new instantiator.
Definition: LinkManager.cpp:23
LinkManager::Link::address
IOpaqueAddress * address()
Access to the object's address.
Definition: LinkManager.cpp:14
LinkManager::m_linkVector
std::vector< Link * > m_linkVector
@ TODO: replace by std::vector> once ROOT does 'automatic' schema conversion fr...
Definition: LinkManager.h:100
std::next
T next(T...args)
LinkManager::clearLinks
void clearLinks()
Remove all possibly existing symbolic links.
Definition: LinkManager.cpp:113
LinkManager::link
Link * link(long id)
Retrieve symbolic link identified by ID.
Definition: LinkManager.cpp:33
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:25
IRegistry::address
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
Gaudi::Utils::Histos::path
GAUDI_API std::string path(const AIDA::IBaseHistogram *aida)
get the path in THS for AIDA histogram
Definition: HistoTableFormat.cpp:191
LinkManager::removeLink
long removeLink(const DataObject *pObject) const
Remove link by object reference.
Definition: LinkManager.cpp:77
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:31
IOpaqueAddress
Opaque address interface definition.
Definition: IOpaqueAddress.h:23
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
LinkManager::Link::m_pObject
DataObject * m_pObject
Pointer to object behind the link.
Definition: LinkManager.h:37
ana.i
list i
Definition: ana.py:128
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