The Gaudi Framework  v30r3 (a5ef0a68)
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 
22 {
23 
24 public:
26  enum DirLinkType { INVALID, VALID };
27 
32  class Link final
33  {
35  // friend class LinkManager;
39  DataObject* m_pObject = nullptr;
41  long m_id = INVALID;
42 
43  public:
45  Link( long id, std::string path, DataObject* pObject = nullptr )
46  : m_path( std::move( path ) ), m_pObject( pObject ), m_id( id )
47  {
48  }
50  Link() = default;
52  void set( long id, std::string path, DataObject* pObject )
53  {
54  setObject( pObject );
55  m_path = std::move( path );
56  m_id = id;
57  }
59  bool operator==( const Link& link ) const { return link.m_path == m_path; }
61  void setObject( const DataObject* pObject ) { m_pObject = const_cast<DataObject*>( pObject ); }
63  const DataObject* object() const { return m_pObject; }
64  DataObject* object() { return m_pObject; }
66  const std::string& path() const { return m_path; }
68  long ID() const { return m_id; }
70  IOpaqueAddress* address();
71  };
72 
73 private:
75  // without the need for friendship. It needs to 'shunt'
76  // all contained links to a new prefix...
77  // The steps to get there are
78  // 1) provide friend access for backwards compatibility
79  // 2) add new interface here
80  // 3) once released, update MergeEventAlg to use the new
81  // interface
82  // 4) revoke friendship.
83  // Now we're at stage 1...
84  friend class MergeEventAlg;
94 
95 public:
97  LinkManager() = default;
99  virtual ~LinkManager();
101  static LinkManager* newInstance();
103  static void setInstantiator( LinkManager* ( *newInstance )() );
105  long size() const { return m_linkVector.size(); }
106  bool empty() const { return m_linkVector.empty(); }
108  Link* link( long id );
110  Link* link( const DataObject* pObject );
112  Link* link( const std::string& path );
114  long addLink( const std::string& path, const DataObject* pObject ) const;
116  long removeLink( const DataObject* pObject ) const;
118  long removeLink( const std::string& fullPath ) const;
120  long removeLink( long id ) const;
122  void clearLinks();
123 };
124 #endif // GAUDIKERNEL_LINKMANAGER_H
T empty(T...args)
STL namespace.
STL class.
T move(T...args)
T size(T...args)
STL class.
Opaque address interface definition.
#define GAUDI_API
Definition: Kernel.h:104
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30