Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  master (d98a2936)
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-2025 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 #pragma once
12 
13 #include <GaudiKernel/Kernel.h>
14 #include <memory>
15 #include <string>
16 #include <vector>
17 
18 class DataObject;
19 class IOpaqueAddress;
20 
28 class GAUDI_API LinkManager final {
29 
30 public:
32  enum DirLinkType { INVALID, VALID };
33 
38  class Link final {
40  std::string m_path;
42  DataObject* m_pObject = nullptr;
44  long m_id = INVALID;
45 
46  public:
48  Link( long id, std::string path, DataObject* pObject = nullptr )
49  : m_path( std::move( path ) ), m_pObject( pObject ), m_id( id ) {}
51  Link() = default;
53  bool operator==( const Link& link ) const { return link.m_path == m_path; }
55  void setObject( const DataObject* pObject ) { m_pObject = const_cast<DataObject*>( pObject ); }
57  const DataObject* object() const { return m_pObject; }
58  DataObject* object() { return m_pObject; }
60  const std::string& path() const { return m_path; }
62  long ID() const { return m_id; }
64  IOpaqueAddress* address();
65  };
66 
67 private:
76  std::vector<Link*> m_linkVector;
77 
78 public:
80  LinkManager() = default;
81  LinkManager( LinkManager&& ) = default;
83  LinkManager( LinkManager const& ) = delete;
84  LinkManager& operator=( LinkManager const& ) = delete;
86  ~LinkManager();
88  long size() const { return m_linkVector.size(); }
89  bool empty() const { return m_linkVector.empty(); }
91  const Link* link( long id ) const;
92  Link* link( long id );
94  const Link* link( const DataObject* pObject ) const;
95  Link* link( const DataObject* pObject );
97  const Link* link( std::string_view path ) const;
98  Link* link( std::string_view path );
100  long addLink( const std::string& path, const DataObject* pObject );
101 
102  auto end() const { return std::default_sentinel; }
103  auto begin() const {
104  class Iterator {
105  int i;
106  LinkManager const* parent;
107 
108  public:
109  Iterator( LinkManager const* p, int i ) : i{ i }, parent{ p } {}
110  bool operator==( std::default_sentinel_t ) const { return i == parent->size(); }
111  Iterator& operator++() {
112  ++i;
113  return *this;
114  }
115  const Link& operator*() const { return *parent->link( i ); }
116  };
117  return Iterator{ this, 0 };
118  }
119 };
Io::INVALID
@ INVALID
Definition: IFileMgr.h:40
Gaudi::Accumulators::operator*
auto operator*(const std::chrono::duration< Rep1, Period > &lhs, const std::chrono::duration< Rep2, Period > &rhs)
Multiplication of two std::chrono::duration objects with same Period.
Definition: Counters.h:40
AtlasMCRecoFullPrecedenceDump.path
path
Definition: AtlasMCRecoFullPrecedenceDump.py:49
GaudiPartProp.decorators.std
std
Definition: decorators.py:32
IOpaqueAddress
Definition: IOpaqueAddress.h:28
GaudiPartProp.tests.id
id
Definition: tests.py:111
Kernel.h
DataObject
Definition: DataObject.h:37
Gaudi::Details::operator==
bool operator==(const PropertyId &lhs, const PropertyId &rhs)
Definition: PropertyId.h:103
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:49
Iterator
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
Definition: Iterator.h:18