The Gaudi Framework  v36r7 (7f57a304)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
LinkManager.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef GAUDIKERNEL_LINKMANAGER_H
12 #define GAUDIKERNEL_LINKMANAGER_H
13 
14 // STL includes
15 #include <memory>
16 #include <string>
17 #include <vector>
18 // Gaudi
19 #include "GaudiKernel/Kernel.h"
20 
21 class DataObject;
22 class IOpaqueAddress;
23 
31 class GAUDI_API LinkManager final {
32 
33 public:
35  enum DirLinkType { INVALID, VALID };
36 
41  class Link final {
45  DataObject* m_pObject = nullptr;
47  long m_id = INVALID;
48 
49  public:
51  Link( long id, std::string path, DataObject* pObject = nullptr )
52  : m_path( std::move( path ) ), m_pObject( pObject ), m_id( id ) {}
54  Link() = default;
56  bool operator==( const Link& link ) const { return link.m_path == m_path; }
58  void setObject( const DataObject* pObject ) { m_pObject = const_cast<DataObject*>( pObject ); }
60  const DataObject* object() const { return m_pObject; }
61  DataObject* object() { return m_pObject; }
63  const std::string& path() const { return m_path; }
65  long ID() const { return m_id; }
67  IOpaqueAddress* address();
68  };
69 
70 private:
80 
81 public:
83  LinkManager() = default;
85  ~LinkManager();
87  static LinkManager* newInstance();
89  static void setInstantiator( LinkManager* ( *newInstance )() );
91  long size() const { return m_linkVector.size(); }
92  bool empty() const { return m_linkVector.empty(); }
94  Link* link( long id );
96  Link* link( const DataObject* pObject );
98  Link* link( std::string_view path );
100  long addLink( const std::string& path, const DataObject* pObject );
101 };
102 #endif // GAUDIKERNEL_LINKMANAGER_H
std::string
STL class.
Io::INVALID
@ INVALID
Definition: IFileMgr.h:47
IOpaqueAddress
Definition: IOpaqueAddress.h:33
std::vector
STL class.
std::vector::size
T size(T... args)
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:961
std
STL namespace.
Kernel.h
DataObject
Definition: DataObject.h:40
std::vector::empty
T empty(T... args)
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:81