Loading [MathJax]/jax/output/HTML-CSS/config.js
The Gaudi Framework  v28r2p1 (f1a77ff4)
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 <vector>
6 #include <string>
7 #include <memory>
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  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  }
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;
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
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:107
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30