The Gaudi Framework  v36r1 (3e2fb5a8)
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 
32 
33 public:
35  enum DirLinkType { INVALID, VALID };
36 
41  class Link final {
43  // friend class LinkManager;
47  DataObject* m_pObject = nullptr;
49  long m_id = INVALID;
50 
51  public:
53  Link( long id, std::string path, DataObject* pObject = nullptr )
54  : m_path( std::move( path ) ), m_pObject( pObject ), m_id( id ) {}
56  Link() = default;
58  void set( long id, std::string path, DataObject* pObject ) {
59  setObject( pObject );
60  m_path = std::move( path );
61  m_id = id;
62  }
64  bool operator==( const Link& link ) const { return link.m_path == m_path; }
66  void setObject( const DataObject* pObject ) { m_pObject = const_cast<DataObject*>( pObject ); }
68  const DataObject* object() const { return m_pObject; }
69  DataObject* object() { return m_pObject; }
71  const std::string& path() const { return m_path; }
73  long ID() const { return m_id; }
75  IOpaqueAddress* address();
76  };
77 
78 private:
80  // without the need for friendship. It needs to 'shunt'
81  // all contained links to a new prefix...
82  // The steps to get there are
83  // 1) provide friend access for backwards compatibility
84  // 2) add new interface here
85  // 3) once released, update MergeEventAlg to use the new
86  // interface
87  // 4) revoke friendship.
88  // Now we're at stage 1...
89  friend class MergeEventAlg;
99 
100 public:
102  LinkManager() = default;
104  virtual ~LinkManager();
106  static LinkManager* newInstance();
108  static void setInstantiator( LinkManager* ( *newInstance )() );
110  long size() const { return m_linkVector.size(); }
111  bool empty() const { return m_linkVector.empty(); }
113  Link* link( long id );
115  Link* link( const DataObject* pObject );
117  Link* link( const std::string& path );
119  long addLink( const std::string& path, const DataObject* pObject ) const;
121  long removeLink( const DataObject* pObject ) const;
123  long removeLink( const std::string& fullPath ) const;
125  long removeLink( long id ) const;
127  void clearLinks();
128 };
129 #endif // GAUDIKERNEL_LINKMANAGER_H
std::string
STL class.
std::move
T move(T... args)
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:943
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