The Gaudi Framework  master (82fdf313)
Loading...
Searching...
No Matches
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
18class DataObject;
19class IOpaqueAddress;
20
29
30public:
33
38 class Link final {
40 std::string m_path;
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 ) {}
50
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; }
60 const std::string& path() const { return m_path; }
62 long ID() const { return m_id; }
64 IOpaqueAddress* address();
65 };
66
67private:
76 std::vector<Link*> m_linkVector;
77
78public:
80 LinkManager() = default;
81 LinkManager( LinkManager&& ) = default;
83 LinkManager( LinkManager const& ) = delete;
84 LinkManager& operator=( LinkManager const& ) = delete;
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};
bool operator==(const GaudiUtils::Allocator< T1 > &, const GaudiUtils::Allocator< T2 > &)
Definition Allocator.h:224
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
Definition Iterator.h:18
#define GAUDI_API
Definition Kernel.h:49
A DataObject is the base class of any identifiable object on any data store.
Definition DataObject.h:37
Opaque address interface definition.
STL namespace.