| The Gaudi Framework v27r1

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

- File List
- File Members

LinkManager.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_LINKMANAGER_H
2 #define GAUDIKERNEL_LINKMANAGER_H
3
4 // STL includes
5 #include <vector>
6 #include <string>
7 #include <memory>
8 // Gaudi
9 #include "GaudiKernel/Kernel.h"
10
11 class DataObject;
12 class IOpaqueAddress;
13
21 class GAUDI_API LinkManager {
22
23 public:
25 enum DirLinkType {INVALID, VALID};
26
31 class Link final {
33 // friend class LinkManager;
35 std::string m_path;
37 DataObject* m_pObject = nullptr;
39 long m_id = INVALID;
40 public:
42 Link(long id, std::string path, DataObject* pObject=nullptr)
43 : m_path(std::move(path)), m_pObject(pObject), m_id(id) {
44 }
46 Link() = default;
48 void set(long id, std::string path, DataObject* pObject) {
49 setObject(pObject);
50 m_path = std::move(path);
51 m_id = id;
52 }
54 bool operator==(const Link& link) const {
55 return link.m_path == m_path;
56 }
58 void setObject(const DataObject* pObject) {
59 m_pObject = const_cast<DataObject*>(pObject);
60 }
62 const DataObject* object() const {
63 return m_pObject;
64 }
65 DataObject* object() {
66 return m_pObject;
67 }
69 const std::string& path() const {
70 return m_path;
71 }
73 long ID() const {
74 return m_id;
75 }
77 IOpaqueAddress* address();
78 };
79
80 private:
82 // without the need for friendship. It needs to 'shunt'
83 // all contained links to a new prefix...
84 // The steps to get there are
85 // 1) provide friend access for backwards compatibility
86 // 2) add new interface here
87 // 3) once released, update MergeEventAlg to use the new
88 // interface
89 // 4) revoke friendship.
90 // Now we're at stage 1...
91 friend class MergeEventAlg;
100 mutable std::vector<Link*> m_linkVector;
101
102 public:
104 LinkManager() = default;
106 virtual ~LinkManager();
108 static LinkManager* newInstance();
110 static void setInstantiator( LinkManager* (*newInstance)() );
112 long size() const { return m_linkVector.size(); }
113 bool empty() const { return m_linkVector.empty(); }
115 Link* link(long id);
117 Link* link(const DataObject* pObject);
119 Link* link(const std::string& path);
121 long addLink(const std::string& path, const DataObject* pObject) const;
123 long removeLink(const DataObject* pObject) const;
125 long removeLink(const std::string& fullPath) const;
127 long removeLink(long id) const;
129 void clearLinks();
130 };
131 #endif // GAUDIKERNEL_LINKMANAGER_H
LinkManager::Link::path
const std::string & path() const
Access to path of object.
Definition: LinkManager.h:69
Kernel.h
std::vector::empty
T empty(T...args)
LinkManager::Link::set
void set(long id, std::string path, DataObject *pObject)
Update the link content.
Definition: LinkManager.h:48
Io::INVALID
Definition: IFileMgr.h:36
std
STL namespace.
std::string
STL class.
LinkManager::Link::setObject
void setObject(const DataObject *pObject)
Update object pointer.
Definition: LinkManager.h:58
LinkManager::DirLinkType
DirLinkType
Directory link types.
Definition: LinkManager.h:25
LinkManager::m_linkVector
std::vector< Link * > m_linkVector
@ TODO: replace by std::vector> once ROOT does 'automatic' schema conversion fr...
Definition: LinkManager.h:100
LinkManager::empty
bool empty() const
Definition: LinkManager.h:113
LinkManager::Link::object
DataObject * object()
Definition: LinkManager.h:65
std::move
T move(T...args)
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::Link::Link
Link(long id, std::string path, DataObject *pObject=nullptr)
Standard constructor.
Definition: LinkManager.h:42
std::vector::size
T size(T...args)
std::vector
STL class.
LinkManager::Link::ID
long ID() const
Link identifier.
Definition: LinkManager.h:73
LinkManager::Link::object
const DataObject * object() const
Const access to data object.
Definition: LinkManager.h:62
LinkManager::Link
Embedded class defining a symbolic link Note: No copy constructor; bitwise copy (done by the compiler...
Definition: LinkManager.h:31
LinkManager::Link::operator==
bool operator==(const Link &link) const
Equality operator: check paths only.
Definition: LinkManager.h:54
IOpaqueAddress
Opaque address interface definition.
Definition: IOpaqueAddress.h:23
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:107
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
LinkManager::Link::m_path
std::string m_path
DataObject is a friend.
Definition: LinkManager.h:35
LinkManager::size
long size() const
Retrieve number of link present.
Definition: LinkManager.h:112