The Gaudi Framework  v31r0 (aeb156f0)
LinkManager Class Reference

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

#include <GaudiKernel/LinkManager.h>

Collaboration diagram for LinkManager:

Classes

class  Link
 Embedded class defining a symbolic link Note: No copy constructor; bitwise copy (done by the compiler) is just fine. More...
 

Public Types

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

Public Member Functions

 LinkManager ()=default
 Standard Constructor. More...
 
virtual ~LinkManager ()
 Standard Destructor. More...
 
long size () const
 Retrieve number of link present. More...
 
bool empty () const
 
Linklink (long id)
 Retrieve symbolic link identified by ID. More...
 
Linklink (const DataObject *pObject)
 Retrieve symbolic link identified by object. More...
 
Linklink (const std::string &path)
 Retrieve symbolic link identified by path. More...
 
long addLink (const std::string &path, const DataObject *pObject) const
 Add link by object reference and path. More...
 
long removeLink (const DataObject *pObject) const
 Remove link by object reference. More...
 
long removeLink (const std::string &fullPath) const
 Remove link by object reference. More...
 
long removeLink (long id) const
 Remove link by link ID. More...
 
void clearLinks ()
 Remove all possibly existing symbolic links. More...
 

Static Public Member Functions

static LinkManagernewInstance ()
 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...
 

Friends

class MergeEventAlg
 @ TODO: provide interface to let MergeEvntAlg do its thing 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 21 of file LinkManager.h.

Member Enumeration Documentation

Directory link types.

Enumerator
INVALID 
VALID 

Definition at line 25 of file LinkManager.h.

Constructor & Destructor Documentation

LinkManager::LinkManager ( )
default

Standard Constructor.

LinkManager::~LinkManager ( )
virtual

Standard Destructor.

destructor

Definition at line 9 of file LinkManager.cpp.

9  {
10  for ( auto& i : m_linkVector ) delete i;
11 }

Member Function Documentation

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

Add link by object reference and path.

Add link by object reference and path string.

Definition at line 54 of file LinkManager.cpp.

54  {
55  long n = 0;
56  for ( auto& lnk : m_linkVector ) {
57  const DataObject* pO = lnk->object();
58  if ( pO && pO == pObject ) return n;
59  if ( lnk->path() == path ) {
60  if ( pObject && pObject != pO ) { lnk->setObject( const_cast<DataObject*>( pObject ) ); }
61  return n;
62  }
63  ++n;
64  }
65  // Link is completely unknown
66  m_linkVector.emplace_back( new Link( m_linkVector.size(), path, const_cast<DataObject*>( pObject ) ) );
67  return m_linkVector.back()->ID();
68 }
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
void LinkManager::clearLinks ( )

Remove all possibly existing symbolic links.

Definition at line 107 of file LinkManager.cpp.

107  {
108  for ( auto& i : m_linkVector ) delete i;
109  m_linkVector.clear();
110 }
bool LinkManager::empty ( ) const
inline

Definition at line 101 of file LinkManager.h.

101 { return m_linkVector.empty(); }
LinkManager::Link * LinkManager::link ( long  id)

Retrieve symbolic link identified by ID.

Definition at line 29 of file LinkManager.cpp.

29  {
30  return ( 0 <= id && (unsigned)id < m_linkVector.size() ) ? m_linkVector[id] : nullptr;
31 }
LinkManager::Link * LinkManager::link ( const DataObject pObject)

Retrieve symbolic link identified by object.

Retrieve symbolic link identified by Object pointer.

Definition at line 34 of file LinkManager.cpp.

34  {
35  if ( pObject ) {
36  for ( auto& i : m_linkVector ) {
37  if ( i->object() == pObject ) return i;
38  }
39  }
40  return nullptr;
41 }
LinkManager::Link * LinkManager::link ( const std::string path)

Retrieve symbolic link identified by path.

Retrieve symbolic link identified by Object path.

Definition at line 44 of file LinkManager.cpp.

44  {
45  if ( 0 != path.length() ) {
46  for ( auto& i : m_linkVector ) {
47  if ( i->path() == path ) return i;
48  }
49  }
50  return nullptr;
51 }
T length(T...args)
LinkManager * LinkManager::newInstance ( )
static

Static instantiation.

Definition at line 26 of file LinkManager.cpp.

26 { return s_newInstance ? ( *s_newInstance )() : new LinkManager(); }
long LinkManager::removeLink ( const DataObject pObject) const

Remove link by object reference.

Definition at line 71 of file LinkManager.cpp.

71  {
72  long n = 0;
73  for ( auto i = m_linkVector.begin(); i != m_linkVector.end(); i++ ) {
74  if ( ( *i )->object() == pObject ) {
75  delete *i;
76  m_linkVector.erase( i );
77  return n;
78  }
79  ++n;
80  }
81  return INVALID;
82 }
long LinkManager::removeLink ( const std::string fullPath) const

Remove link by object reference.

Definition at line 85 of file LinkManager.cpp.

85  {
86  long n = 0;
87  for ( auto i = m_linkVector.begin(); i != m_linkVector.end(); i++ ) {
88  if ( ( *i )->path() == path ) {
89  delete *i;
90  m_linkVector.erase( i );
91  return n;
92  }
93  n++;
94  }
95  return INVALID;
96 }
long LinkManager::removeLink ( long  id) const

Remove link by link ID.

Definition at line 99 of file LinkManager.cpp.

99  {
100  auto i = std::next( m_linkVector.begin(), id );
101  delete *i;
102  m_linkVector.erase( i );
103  return id;
104 }
T next(T...args)
void LinkManager::setInstantiator ( LinkManager *(*)()  newInstance)
static

Assign new instantiator.

Definition at line 23 of file LinkManager.cpp.

23 { s_newInstance = newInstance; }
long LinkManager::size ( ) const
inline

Retrieve number of link present.

Definition at line 100 of file LinkManager.h.

100 { return m_linkVector.size(); }

Friends And Related Function Documentation

friend class MergeEventAlg
friend

@ TODO: provide interface to let MergeEvntAlg do its thing

Definition at line 79 of file LinkManager.h.

Member Data Documentation

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

@ 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 88 of file LinkManager.h.


The documentation for this class was generated from the following files: