Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 public:
25  enum DirLinkType { INVALID, VALID };
26 
31  class Link final {
33  // friend class LinkManager;
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;
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
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:71
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30