The Gaudi Framework  v36r10 (fc05264c)
LinkManager Class Referencefinal

#include <GaudiKernel/LinkManager.h>

Collaboration diagram for LinkManager:

Classes

class  Link
 Embedded class defining a symbolic link Note: No explicit copy constructor; implicit compiler generated one is just fine. More...
 
struct  Sentinel
 

Public Types

enum  DirLinkType { INVALID, VALID }
 Directory link types. More...
 

Public Member Functions

 LinkManager ()=default
 Standard Constructor. More...
 
 ~LinkManager ()
 Standard Destructor. More...
 
long size () const
 Retrieve number of link present. More...
 
bool empty () const
 
const Link * link (long id) const
 Retrieve symbolic link identified by ID. More...
 
Link * link (long id)
 
const Link * link (const DataObject *pObject) const
 Retrieve symbolic link identified by object. More...
 
Link * link (const DataObject *pObject)
 
const Link * link (std::string_view path) const
 Retrieve symbolic link identified by path. More...
 
Link * link (std::string_view path)
 
long addLink (const std::string &path, const DataObject *pObject)
 Add link by object reference and path. More...
 
Sentinel end () const
 
auto begin () const
 

Static Public Member Functions

static LinkManager * newInstance ()
 Static instantiation. More...
 
static void setInstantiator (LinkManager *(*newInstance)())
 Assign new instantiator. More...
 

Private Attributes

std::vector< Link * > m_linkVector
 @ TODO: replace by std::vector<std::unique_ptr<Link>> once ROOT does 'automatic' schema conversion from T* to std::unique_ptr<T>... More...
 

Detailed Description

A LinkManager is the object aggregated into a DataObject, which is responsible for the handling of non-tree like links.

Author
M.Frank

Definition at line 31 of file LinkManager.h.

Member Enumeration Documentation

◆ DirLinkType

Directory link types.

Enumerator
INVALID 
VALID 

Definition at line 35 of file LinkManager.h.

35 { INVALID, VALID };

Constructor & Destructor Documentation

◆ LinkManager()

LinkManager::LinkManager ( )
default

Standard Constructor.

◆ ~LinkManager()

LinkManager::~LinkManager ( )

Standard Destructor.

destructor

Definition at line 29 of file LinkManager.cpp.

29  {
30  for ( auto& i : m_linkVector ) delete i;
31 }

Member Function Documentation

◆ addLink()

long LinkManager::addLink ( const std::string &  path,
const DataObject *  pObject 
)

Add link by object reference and path.

Add link by object reference and path string.

Definition at line 75 of file LinkManager.cpp.

75  {
76  long n = 0;
77  for ( auto& lnk : m_linkVector ) {
78  const DataObject* pO = lnk->object();
79  if ( pO && pO == pObject ) return n;
80  if ( lnk->path() == path ) {
81  if ( pObject && pObject != pO ) { lnk->setObject( const_cast<DataObject*>( pObject ) ); }
82  return n;
83  }
84  ++n;
85  }
86  // Link is completely unknown
87  return m_linkVector.emplace_back( new Link( m_linkVector.size(), path, const_cast<DataObject*>( pObject ) ) )->ID();
88 }

◆ begin()

auto LinkManager::begin ( ) const
inline

Definition at line 107 of file LinkManager.h.

107  {
108  class Iterator {
109  int i;
110  LinkManager const* parent;
111 
112  public:
113  Iterator( LinkManager const* p, int i ) : i{ i }, parent{ p } {}
114  bool operator==( Sentinel ) const { return i == parent->size(); }
115  bool operator!=( Sentinel ) const { return !( *this == Sentinel{} ); }
116  Iterator& operator++() {
117  ++i;
118  return *this;
119  }
120  const Link& operator*() const { return *parent->link( i ); }
121  };
122  return Iterator{ this, 0 };
123  }

◆ empty()

bool LinkManager::empty ( ) const
inline

Definition at line 92 of file LinkManager.h.

92 { return m_linkVector.empty(); }

◆ end()

Sentinel LinkManager::end ( ) const
inline

Definition at line 106 of file LinkManager.h.

106 { return {}; }

◆ link() [1/6]

LinkManager::Link * LinkManager::link ( const DataObject *  pObject)

Definition at line 62 of file LinkManager.cpp.

62  {
63  return pObject ? findLink( m_linkVector, [=]( auto* j ) { return j->object() == pObject; } ) : nullptr;
64 }

◆ link() [2/6]

const LinkManager::Link * LinkManager::link ( const DataObject *  pObject) const

Retrieve symbolic link identified by object.

Retrieve symbolic link identified by Object pointer.

Definition at line 58 of file LinkManager.cpp.

58  {
59  return pObject ? findLink( m_linkVector, [=]( auto* j ) { return j->object() == pObject; } ) : nullptr;
60 }

◆ link() [3/6]

LinkManager::Link * LinkManager::link ( long  id)

Definition at line 53 of file LinkManager.cpp.

53  {
54  return ( 0 <= id && (unsigned)id < m_linkVector.size() ) ? m_linkVector[id] : nullptr;
55 }

◆ link() [4/6]

const LinkManager::Link * LinkManager::link ( long  id) const

Retrieve symbolic link identified by ID.

Definition at line 49 of file LinkManager.cpp.

49  {
50  return ( 0 <= id && (unsigned)id < m_linkVector.size() ) ? m_linkVector[id] : nullptr;
51 }

◆ link() [5/6]

LinkManager::Link * LinkManager::link ( std::string_view  path)

Definition at line 70 of file LinkManager.cpp.

70  {
71  return !path.empty() ? findLink( m_linkVector, [=]( auto* j ) { return j->path() == path; } ) : nullptr;
72 }

◆ link() [6/6]

const LinkManager::Link * LinkManager::link ( std::string_view  path) const

Retrieve symbolic link identified by path.

Retrieve symbolic link identified by Object path.

Definition at line 67 of file LinkManager.cpp.

67  {
68  return !path.empty() ? findLink( m_linkVector, [=]( auto* j ) { return j->path() == path; } ) : nullptr;
69 }

◆ newInstance()

LinkManager * LinkManager::newInstance ( )
static

Static instantiation.

Definition at line 46 of file LinkManager.cpp.

46 { return s_newInstance ? ( *s_newInstance )() : new LinkManager(); }

◆ setInstantiator()

void LinkManager::setInstantiator ( LinkManager *(*)()  newInstance)
static

Assign new instantiator.

Definition at line 43 of file LinkManager.cpp.

43 { s_newInstance = newInstance; }

◆ size()

long LinkManager::size ( ) const
inline

Retrieve number of link present.

Definition at line 91 of file LinkManager.h.

91 { return m_linkVector.size(); }

Member Data Documentation

◆ m_linkVector

std::vector<Link*> LinkManager::m_linkVector
private

@ TODO: replace by std::vector<std::unique_ptr<Link>> once ROOT does 'automatic' schema conversion from T* to std::unique_ptr<T>...

Or, even better, just std::vector<Link>, given that Link is barely larger than a pointer (40 vs. 8 bytes) – but that requires more invasive schema evolution.

The vector containing all links which are non-tree like

Definition at line 79 of file LinkManager.h.


The documentation for this class was generated from the following files:
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
Gaudi::Allocator::operator!=
constexpr bool operator!=(Arena< Resource, T, DefaultResource > const &lhs, Arena< Resource, U, DefaultResource > const &rhs)
Definition: Arena.h:86
GaudiPython.HistoUtils.path
path
Definition: HistoUtils.py:961
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:235
DataObject
Definition: DataObject.h:40
Gaudi::Details::operator==
bool operator==(const PropertyId &lhs, const PropertyId &rhs)
Definition: PropertyId.h:110
Iterator
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
Definition: Iterator.h:28