| # Gaudi Framework, version v20r3
Generated: 24 Nov 2008

# 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
    00008 class DataObject;
    00009 class IOpaqueAddress;
    00010
    00018 class LinkManager   {
    00019
    00020 public:
    00022   enum DirLinkType {INVALID, VALID};
    00023
    00028   class Link  {
    00030     friend class LinkManager;
    00031   protected:
    00033     std::string m_path;
    00035     DataObject* m_pObject;
    00037     long        m_id;
    00038   public:
    00040     Link(long id, const std::string& path, const DataObject* pObject=0)
    00041     : m_path(path), m_id(id) {
    00042       setObject(pObject);
    00043     }
    00045     Link() : m_path(""), m_pObject(0), m_id(INVALID) {
    00046     }
    00048     Link& operator=(const Link& link)  {
    00049       setObject(link.m_pObject);
    00050       m_path = link.m_path;
    00051       m_id   = link.m_id;
    00052       return *this;
    00053     }
    00055     virtual ~Link() {
    00056     }
    00058     void set(long id, const std::string& path, const DataObject* pObject)   {
    00059       setObject(pObject);
    00060       m_path = path;
    00061       m_id   = id;
    00062     }
    00064     bool operator==(const Link& link)  const  {
    00065       return link.m_path == m_path;
    00066     }
    00068     void setObject(const DataObject* pObject)   {
    00069       m_pObject = const_cast<DataObject*>(pObject);
    00070     }
    00072     DataObject* object()  const  {
    00073       return m_pObject;
    00074     }
    00076     const std::string& path()   const   {
    00077       return m_path;
    00078     }
    00080     long ID()  const    {
    00081       return m_id;
    00082     }
    00084     virtual IOpaqueAddress* address();
    00085   };
    00086   typedef std::vector<Link*>           LinkVector;
    00088   typedef LinkVector::iterator         LinkIterator;
    00090   typedef LinkVector::const_iterator   ConstLinkIterator;
    00091
    00093   mutable LinkVector m_linkVector;
    00094
    00095 public:
    00097   LinkManager();
    00099   virtual ~LinkManager();
    00101   static LinkManager* newInstance();
    00103   static void setInstantiator( LinkManager* (*newInstance)() );
    00105   long size()   const   {
    00106     return m_linkVector.size();
    00107   }
    00109   Link* link(long id);
    00111   Link* link(const DataObject* pObject);
    00113   Link* link(const std::string& path);
    00115   long addLink(const std::string& path, const DataObject* pObject)   const;
    00117   long removeLink(const DataObject* pObject)   const;
    00119   long removeLink(const std::string& fullPath)   const;
    00121   long removeLink(long id)   const;
    00123   void clearLinks();
    00124 };
    00125 #endif // GAUDIKERNEL_LINKMANAGER_H