All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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, INVALID, VALID }
 Directory link types. More...
 
enum  DirLinkType { INVALID, VALID, 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...
 
 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...
 
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 
INVALID 
VALID 

Definition at line 25 of file LinkManager.h.

Directory link types.

Enumerator
INVALID 
VALID 
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 }
list i
Definition: ana.py:128
LinkManager::LinkManager ( )
default

Standard Constructor.

virtual LinkManager::~LinkManager ( )
virtual

Standard Destructor.

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 58 of file LinkManager.cpp.

58  {
59  long n = 0;
60  for ( auto& lnk : m_linkVector ) {
61  const DataObject* pO = lnk->object();
62  if ( pO && pO == pObject ) return n;
63  if ( lnk->path() == path ) {
64  if ( pObject && pObject != pO ) {
65  lnk->setObject(const_cast<DataObject*>(pObject));
66  }
67  return n;
68  }
69  ++n;
70  }
71  // Link is completely unknown
72  m_linkVector.emplace_back( new Link(m_linkVector.size(), path, const_cast<DataObject*>(pObject)) );
73  return m_linkVector.back()->ID();
74 }
list path
Definition: __init__.py:15
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
long LinkManager::addLink ( const std::string &  path,
const DataObject pObject 
) const

Add link by object reference and path.

void LinkManager::clearLinks ( )

Remove all possibly existing symbolic links.

Definition at line 113 of file LinkManager.cpp.

113  {
114  for (auto& i : m_linkVector) delete i;
115  m_linkVector.clear();
116 }
list i
Definition: ana.py:128
void LinkManager::clearLinks ( )

Remove all possibly existing symbolic links.

bool LinkManager::empty ( ) const
inline

Definition at line 113 of file LinkManager.h.

113 { return m_linkVector.empty(); }
bool LinkManager::empty ( ) const
inline

Definition at line 113 of file LinkManager.h.

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

Retrieve symbolic link identified by ID.

Definition at line 33 of file LinkManager.cpp.

33  {
34  return (0<=id && (unsigned)id < m_linkVector.size()) ? m_linkVector[id] : nullptr;
35 }
Link* LinkManager::link ( long  id)

Retrieve symbolic link identified by ID.

Link* LinkManager::link ( const DataObject pObject)

Retrieve symbolic link identified by object.

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

Retrieve symbolic link identified by object.

Retrieve symbolic link identified by Object pointer.

Definition at line 38 of file LinkManager.cpp.

38  {
39  if ( pObject ) {
40  for ( auto& i : m_linkVector ) {
41  if ( i->object() == pObject ) return i;
42  }
43  }
44  return nullptr;
45 }
list i
Definition: ana.py:128
Link* LinkManager::link ( const std::string &  path)

Retrieve symbolic link identified by path.

LinkManager::Link * LinkManager::link ( const std::string &  path)

Retrieve symbolic link identified by path.

Retrieve symbolic link identified by Object path.

Definition at line 48 of file LinkManager.cpp.

48  {
49  if ( 0 != path.length() ) {
50  for ( auto & i : m_linkVector ) {
51  if ( i->path() == path ) return i;
52  }
53  }
54  return nullptr;
55 }
list path
Definition: __init__.py:15
list i
Definition: ana.py:128
LinkManager * LinkManager::newInstance ( )
static

Static instantiation.

Definition at line 28 of file LinkManager.cpp.

28  {
29  return s_newInstance ? (*s_newInstance)() : new LinkManager();
30 }
static LinkManager* LinkManager::newInstance ( )
static

Static instantiation.

long LinkManager::removeLink ( const DataObject pObject) const

Remove link by object reference.

Definition at line 77 of file LinkManager.cpp.

77  {
78  long n = 0;
79  for ( auto i = m_linkVector.begin(); i != m_linkVector.end(); i++ ) {
80  if ( (*i)->object() == pObject ) {
81  delete *i;
82  m_linkVector.erase(i);
83  return n;
84  }
85  ++n;
86  }
87  return INVALID;
88 }
list i
Definition: ana.py:128
long LinkManager::removeLink ( const DataObject pObject) const

Remove link by object reference.

long LinkManager::removeLink ( const std::string &  fullPath) const

Remove link by object reference.

Definition at line 91 of file LinkManager.cpp.

91  {
92  long n = 0;
93  for ( auto i = m_linkVector.begin(); i != m_linkVector.end(); i++ ) {
94  if ( (*i)->path() == path ) {
95  delete *i;
96  m_linkVector.erase(i);
97  return n;
98  }
99  n++;
100  }
101  return INVALID;
102 }
list path
Definition: __init__.py:15
list i
Definition: ana.py:128
long LinkManager::removeLink ( const std::string &  fullPath) const

Remove link by object reference.

long LinkManager::removeLink ( long  id) const

Remove link by link ID.

Definition at line 105 of file LinkManager.cpp.

105  {
106  auto i = std::next(m_linkVector.begin(), id );
107  delete *i;
108  m_linkVector.erase(i);
109  return id;
110 }
list i
Definition: ana.py:128
long LinkManager::removeLink ( long  id) const

Remove link by link ID.

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

Assign new instantiator.

Definition at line 23 of file LinkManager.cpp.

23  {
24  s_newInstance = newInstance;
25 }
static void LinkManager::setInstantiator ( LinkManager *(*)()  newInstance)
static

Assign new instantiator.

long LinkManager::size ( ) const
inline

Retrieve number of link present.

Definition at line 112 of file LinkManager.h.

112 { return m_linkVector.size(); }
long LinkManager::size ( ) const
inline

Retrieve number of link present.

Definition at line 112 of file LinkManager.h.

112 { return m_linkVector.size(); }

Friends And Related Function Documentation

MergeEventAlg
friend

@ TODO: provide interface to let MergeEvntAlg do its thing

Definition at line 91 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 100 of file LinkManager.h.


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