| The Gaudi Framework v32r1 (f65d50dc)

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 <memory>
6 #include <string>
7 #include <vector>
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
41 public:
43 Link( long id, std::string path, DataObject* pObject = nullptr )
44 : m_path( std::move( path ) ), m_pObject( pObject ), m_id( id ) {}
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 { return link.m_path == m_path; }
56 void setObject( const DataObject* pObject ) { m_pObject = const_cast<DataObject*>( pObject ); }
58 const DataObject* object() const { return m_pObject; }
59 DataObject* object() { return m_pObject; }
61 const std::string& path() const { return m_path; }
63 long ID() const { return m_id; }
65 IOpaqueAddress* address();
66 };
67
68 private:
70 // without the need for friendship. It needs to 'shunt'
71 // all contained links to a new prefix...
72 // The steps to get there are
73 // 1) provide friend access for backwards compatibility
74 // 2) add new interface here
75 // 3) once released, update MergeEventAlg to use the new
76 // interface
77 // 4) revoke friendship.
78 // Now we're at stage 1...
79 friend class MergeEventAlg;
88 mutable std::vector<Link*> m_linkVector;
89
90 public:
92 LinkManager() = default;
94 virtual ~LinkManager();
96 static LinkManager* newInstance();
98 static void setInstantiator( LinkManager* ( *newInstance )() );
100 long size() const { return m_linkVector.size(); }
101 bool empty() const { return m_linkVector.empty(); }
103 Link* link( long id );
105 Link* link( const DataObject* pObject );
107 Link* link( const std::string& path );
109 long addLink( const std::string& path, const DataObject* pObject ) const;
111 long removeLink( const DataObject* pObject ) const;
113 long removeLink( const std::string& fullPath ) const;
115 long removeLink( long id ) const;
117 void clearLinks();
118 };
119 #endif // GAUDIKERNEL_LINKMANAGER_H
LinkManager::Link::object
const DataObject * object() const
Const access to data object.
Definition: LinkManager.h:58
Kernel.h
std::vector::empty
T empty(T... args)
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:932
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:37
std
STL namespace.
std::string
STL class.
LinkManager::empty
bool empty() const
Definition: LinkManager.h:101
LinkManager::Link::setObject
void setObject(const DataObject *pObject)
Update object pointer.
Definition: LinkManager.h:56
LinkManager::DirLinkType
DirLinkType
Directory link types.
Definition: LinkManager.h:25
LinkManager::m_linkVector
std::vector< Link * > m_linkVector
@ TODO: replace by std::vector<std::unique_ptr<Link>> once ROOT does 'automatic' schema conversion fr...
Definition: LinkManager.h:88
LinkManager::Link::path
const std::string & path() const
Access to path of object.
Definition: LinkManager.h:61
LinkManager::Link::object
DataObject * object()
Definition: LinkManager.h:59
std::move
T move(T... args)
LinkManager::Link::Link
Link(long id, std::string path, DataObject *pObject=nullptr)
Standard constructor.
Definition: LinkManager.h:43
std::vector::size
T size(T... args)
std::vector
STL class.
LinkManager::size
long size() const
Retrieve number of link present.
Definition: LinkManager.h:100
LinkManager::Link::operator==
bool operator==(const Link &link) const
Equality operator: check paths only.
Definition: LinkManager.h:54
LinkManager::Link::ID
long ID() const
Link identifier.
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:31
IOpaqueAddress
Opaque address interface definition.
Definition: IOpaqueAddress.h:23
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:71
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