| # Gaudi Framework, version v20r2
Generated: 18 Jul 2008

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

- Search for |

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# LinkManager Class Reference

`#include <GaudiKernel/LinkManager.h>`

Collaboration diagram for LinkManager:

[legend]
List of all members.

## 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 18 of file LinkManager.h.

## Public Types
enum | DirLinkType { INVALID, VALID }
| Directory link types. More...
typedef std::vector< Link * > | LinkVector
typedef LinkVector::iterator | LinkIterator
| Data type: iterator over leaf links.
typedef LinkVector::const_iterator | ConstLinkIterator
| Data type: iterator over leaf links (CONST).
## Public Member Functions
| LinkManager ()
| Standard Constructor.
virtual | ~LinkManager ()
| Standard Destructor.
long | size () const
| Retrieve number of link present.
Link * | link (long id)
| Retrieve symbolic link identified by ID.
Link * | link (const DataObject *pObject)
| Retrieve symbolic link identified by object.
Link * | link (const std::string &path)
| Retrieve symbolic link identified by path.
long | addLink (const std::string &path, const DataObject *pObject) const
| Add link by object reference and path.
long | removeLink (const DataObject *pObject) const
| Remove link by object reference.
long | removeLink (const std::string &fullPath) const
| Remove link by object reference.
long | removeLink (long id) const
| Remove link by link ID.
void | clearLinks ()
| Remove all possibly existing symbolic links.
## Static Public Member Functions
static LinkManager * | newInstance ()
| Static instantiation.
static void | setInstantiator (LinkManager *(*newInstance)())
| Assign new instantiator.
## Public Attributes
LinkVector | m_linkVector
| The vector containing all links which are non-tree like.
## Classes
class | Link
| Embeeded class defining a symbolic link Note: No copy constructor; bitwise copy (done by the compiler) is just fine. More...

## Member Typedef Documentation

typedef std::vector<Link*> LinkManager::LinkVector

Definition at line 86 of file LinkManager.h.

typedef LinkVector::iterator LinkManager::LinkIterator

Data type: iterator over leaf links.

Definition at line 88 of file LinkManager.h.

typedef LinkVector::const_iterator LinkManager::ConstLinkIterator

Data type: iterator over leaf links (CONST).

Definition at line 90 of file LinkManager.h.

## Member Enumeration Documentation

enum LinkManager::DirLinkType

Directory link types.

Enumerator:

  INVALID |
  VALID |

Definition at line 22 of file LinkManager.h.

    00022 {INVALID, VALID};

## Constructor & Destructor Documentation

LinkManager::LinkManager | ( |  | ) |

Standard Constructor.

Definition at line 32 of file LinkManager.cpp.

Referenced by newInstance().

    00032                           {
    00033 }

LinkManager::~LinkManager | ( |  | ) | `[virtual]`

Standard Destructor.

Definition at line 36 of file LinkManager.cpp.

References clearLinks().

    00036                              {
    00037   clearLinks();
    00038 }

## Member Function Documentation

LinkManager * LinkManager::newInstance | ( |  | ) | `[static]`

Static instantiation.

Definition at line 27 of file LinkManager.cpp.

References LinkManager(), and s_newInstance.

Referenced by DataObject::DataObject(), and setInstantiator().

    00027                                        {
    00028   return s_newInstance ? (*s_newInstance)() : new LinkManager();
    00029 }

void LinkManager::setInstantiator | ( | LinkManager *(*)() | newInstance | ) | `[static]`

Assign new instantiator.

Definition at line 22 of file LinkManager.cpp.

References newInstance(), and s_newInstance.

    00022                                                                  {
    00023   s_newInstance = newInstance;
    00024 }

long LinkManager::size | ( |  | ) | const`[inline]`

Retrieve number of link present.

Definition at line 105 of file LinkManager.h.

References m_linkVector, and std::vector< _Tp, _Alloc >::size().

Referenced by PoolDbBaseCnv::dumpReferences(), PoolDbBaseCnv::setReferences(), and PoolDbBaseCnv::updateObjRefs().

    00105                         {
    00106     return m_linkVector.size();
    00107   }

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

Retrieve symbolic link identified by ID.

Definition at line 41 of file LinkManager.cpp.

References m_linkVector, and std::vector< _Tp, _Alloc >::size().

Referenced by Objects::access(), SmartRefBase::accessData(), addLink(), PoolDbBaseCnv::dumpReferences(), SmartRefBase::isEqualEx(), LinkManager::Link::operator=(), LinkManager::Link::operator==(), SmartRefBase::path(), PoolDbBaseCnv::setReferences(), and PoolDbBaseCnv::updateObjRefs().

    00041                                              {
    00042   return (0<=id && (unsigned)id < m_linkVector.size()) ? m_linkVector[id] : 0;
    00043 }

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

Retrieve symbolic link identified by object.

Definition at line 46 of file LinkManager.cpp.

References std::vector< _Tp, _Alloc >::begin(), std::vector< _Tp, _Alloc >::end(), and m_linkVector.

    00046                                                              {
    00047   if ( 0 != pObject )   {
    00048     for ( LinkVector::iterator i = m_linkVector.begin(); i != m_linkVector.end(); i++ )   {
    00049       if ( (*i)->object() == pObject )    {
    00050         return (*i);
    00051       }
    00052     }
    00053   }
    00054   return 0;
    00055 }

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

Retrieve symbolic link identified by path.

Definition at line 58 of file LinkManager.cpp.

References std::vector< _Tp, _Alloc >::begin(), std::vector< _Tp, _Alloc >::end(), std::basic_string< _CharT, _Traits, _Alloc >::length(), m_linkVector, and Gaudi::Utils::Histos::path().

    00058                                                          {
    00059   if ( 0 != path.length() )   {
    00060     for ( LinkVector::iterator i = m_linkVector.begin(); i != m_linkVector.end(); i++ )   {
    00061       if ( (*i)->path() == path )    {
    00062         return (*i);
    00063       }
    00064     }
    00065   }
    00066   return 0;
    00067 }

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

Add link by object reference and path.

Definition at line 70 of file LinkManager.cpp.

References std::vector< _Tp, _Alloc >::begin(), std::vector< _Tp, _Alloc >::end(), LinkManager::Link::ID(), link(), m_linkVector, Gaudi::Utils::Histos::path(), std::vector< _Tp, _Alloc >::push_back(), and std::vector< _Tp, _Alloc >::size().

Referenced by PoolDbIOHandler< T >::put(), and PoolDbBaseCnv::setReferences().

    00070                                                                                     {
    00071   long n = 0;
    00072   for ( LinkVector::const_iterator i = m_linkVector.begin(); i != m_linkVector.end(); i++ )   {
    00073     Link* lnk = *i;
    00074     const DataObject* pO = lnk->object();
    00075     if ( 0 != pO && pO == pObject )   {
    00076       return n;
    00077     }
    00078     bool same_path = lnk->path() == path;
    00079     if ( same_path ) {
    00080       if ( 0 != pObject && pObject != pO )  {
    00081         lnk->setObject(pObject);
    00082       }
    00083       return n;
    00084     }
    00085     n++;
    00086   }
    00087   // Link is completely unknown
    00088   Link* link = new Link(m_linkVector.size(), path, pObject);
    00089   m_linkVector.push_back( link );
    00090   return link->ID();
    00091 }

long LinkManager::removeLink | ( | const DataObject * | pObject | ) | const

Remove link by object reference.

Definition at line 94 of file LinkManager.cpp.

References std::vector< _Tp, _Alloc >::begin(), std::vector< _Tp, _Alloc >::end(), std::vector< _Tp, _Alloc >::erase(), INVALID, and m_linkVector.

    00094                                                               {
    00095   long n = 0;
    00096   for ( LinkVector::iterator i = m_linkVector.begin(); i != m_linkVector.end(); i++ )   {
    00097     if ( (*i)->object() == pObject )    {
    00098       delete (*i);
    00099       m_linkVector.erase(i);
    00100       return n;
    00101     }
    00102     n++;
    00103   }
    00104   return INVALID;
    00105 }

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

Remove link by object reference.

Definition at line 108 of file LinkManager.cpp.

References std::vector< _Tp, _Alloc >::begin(), std::vector< _Tp, _Alloc >::end(), std::vector< _Tp, _Alloc >::erase(), INVALID, m_linkVector, and Gaudi::Utils::Histos::path().

    00108                                                           {
    00109   long n = 0;
    00110   for ( LinkVector::iterator i = m_linkVector.begin(); i != m_linkVector.end(); i++ )   {
    00111     if ( (*i)->path() == path )    {
    00112       delete (*i);
    00113       m_linkVector.erase(i);
    00114       return n;
    00115     }
    00116     n++;
    00117   }
    00118   return INVALID;
    00119 }

long LinkManager::removeLink | ( | long | id | ) | const

Remove link by link ID.

Definition at line 122 of file LinkManager.cpp.

References std::vector< _Tp, _Alloc >::begin(), std::vector< _Tp, _Alloc >::erase(), INVALID, and m_linkVector.

    00122                                             {
    00123   LinkVector::iterator i = m_linkVector.begin();
    00124   i += id;
    00125   delete (*i);
    00126   m_linkVector.erase(i);
    00127   return id;
    00128   return INVALID;
    00129 }

void LinkManager::clearLinks | ( |  | ) |

Remove all possibly existing symbolic links.

Definition at line 132 of file LinkManager.cpp.

References std::vector< _Tp, _Alloc >::begin(), std::vector< _Tp, _Alloc >::end(), std::vector< _Tp, _Alloc >::erase(), and m_linkVector.

Referenced by ~LinkManager().

    00132                               {
    00133   for ( LinkVector::iterator i = m_linkVector.begin(); i != m_linkVector.end(); i++ )   {
    00134     delete (*i);
    00135   }
    00136   m_linkVector.erase(m_linkVector.begin(), m_linkVector.end());
    00137 }

## Member Data Documentation

LinkVector LinkManager::m_linkVector`[mutable]`

The vector containing all links which are non-tree like.

Definition at line 93 of file LinkManager.h.

Referenced by addLink(), clearLinks(), link(), removeLink(), and size().

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r2/GaudiKernel/v25r2/GaudiKernel/LinkManager.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r2/GaudiKernel/v25r2/src/Lib/LinkManager.cpp