| # Gaudi Framework, version v22r4 |

Home |  | Generated: Fri Sep 2 2011

# LinkManager.h

Go to the documentation of this file.

    00001 #ifndef GAUDIKERNEL_LINKMANAGER_H
    00002 #define GAUDIKERNEL_LINKMANAGER_H
    00003
    00004 // STL includes
    00005 #include <vector>
    00006 #include <string>
    00007 // Gaudi
    00008 #include "GaudiKernel/Kernel.h"
    00009
    00010 class DataObject;
    00011 class IOpaqueAddress;
    00012
    00020 class GAUDI_API LinkManager {
    00021
    00022 public:
    00024   enum DirLinkType {INVALID, VALID};
    00025
    00030   class Link  {
    00032     friend class LinkManager;
    00033   protected:
    00035     std::string m_path;
    00037     DataObject* m_pObject;
    00039     long        m_id;
    00040   public:
    00042     Link(long id, const std::string& path, const DataObject* pObject=0)
    00043     : m_path(path), m_id(id) {
    00044       setObject(pObject);
    00045     }
    00047     Link() : m_path(""), m_pObject(0), m_id(INVALID) {
    00048     }
    00050     Link& operator=(const Link& link)  {
    00051       setObject(link.m_pObject);
    00052       m_path = link.m_path;
    00053       m_id   = link.m_id;
    00054       return *this;
    00055     }
    00057     virtual ~Link() {
    00058     }
    00060     void set(long id, const std::string& path, const DataObject* pObject)   {
    00061       setObject(pObject);
    00062       m_path = path;
    00063       m_id   = id;
    00064     }
    00066     bool operator==(const Link& link)  const  {
    00067       return link.m_path == m_path;
    00068     }
    00070     void setObject(const DataObject* pObject)   {
    00071       m_pObject = const_cast<DataObject*>(pObject);
    00072     }
    00074     DataObject* object()  const  {
    00075       return m_pObject;
    00076     }
    00078     const std::string& path()   const   {
    00079       return m_path;
    00080     }
    00082     long ID()  const    {
    00083       return m_id;
    00084     }
    00086     virtual IOpaqueAddress* address();
    00087   };
    00088   typedef std::vector<Link*>           LinkVector;
    00090   typedef LinkVector::iterator         LinkIterator;
    00092   typedef LinkVector::const_iterator   ConstLinkIterator;
    00093
    00095   mutable LinkVector m_linkVector;
    00096
    00097 public:
    00099   LinkManager();
    00101   virtual ~LinkManager();
    00103   static LinkManager* newInstance();
    00105   static void setInstantiator( LinkManager* (*newInstance)() );
    00107   long size()   const   {
    00108     return m_linkVector.size();
    00109   }
    00111   Link* link(long id);
    00113   Link* link(const DataObject* pObject);
    00115   Link* link(const std::string& path);
    00117   long addLink(const std::string& path, const DataObject* pObject)   const;
    00119   long removeLink(const DataObject* pObject)   const;
    00121   long removeLink(const std::string& fullPath)   const;
    00123   long removeLink(long id)   const;
    00125   void clearLinks();
    00126 };
    00127 #endif // GAUDIKERNEL_LINKMANAGER_H

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines