| # Gaudi Framework, version v21r10p1 |

Home |  | Generated: 29 Jul 2010

# SmartRefBase.h

Go to the documentation of this file.

    00001 //      ====================================================================
    00002 //      SmartRefBase.h
    00003 //      --------------------------------------------------------------------
    00004 //
    00005 //      Package   : Gaudi/Kernel
    00006 //              Base class for SmartReference objects
    00007 //
    00008 //      Author    : Markus Frank
    00009 //
    00010 //      ====================================================================
    00011 #ifndef KERNEL_SMARTREFBASE_H
    00012 #define KERNEL_SMARTREFBASE_H 1
    00013
    00014 // Framework include files
    00015 #include "GaudiKernel/StreamBuffer.h"
    00016
    00017 class ObjectContainerBase;
    00018 class SmartRefBase;
    00019 class ContainedObject;
    00020 class DataObject;
    00021
    00047 class GAUDI_API SmartRefBase {
    00048 public:
    00050   mutable long                    m_hintID;
    00052   mutable long                    m_linkID;
    00054   mutable const DataObject*       m_data;
    00056   mutable const ContainedObject*  m_contd;
    00057
    00058   mutable long                    m_type;
    00059
    00060   enum { DATAOBJECT, CONTAINEDOBJECT };
    00061
    00063   const ContainedObject* accessData ( const ContainedObject* typ )   const;
    00065   const DataObject* accessData ( const DataObject* typ )   const;
    00066
    00068   bool isEqualEx(const DataObject* pObj, const SmartRefBase& c)  const;
    00070   bool isEqualEx(const ContainedObject* pObj, const SmartRefBase& c)  const;
    00072   bool isEqual          (const ContainedObject* /* pObj */, const SmartRefBase& c)  const  {
    00073     return (m_hintID == c.m_hintID && m_linkID == c.m_linkID &&
    00074             m_data   == c.m_data   && m_contd  == c.m_contd);
    00075   }
    00077   bool isEqual          (const DataObject* /* pObj */, const SmartRefBase& c)  const    {
    00078     return m_linkID == c.m_linkID && m_data   == c.m_data;
    00079   }
    00081   void writeObject  (const DataObject* pObject, StreamBuffer& s)  const   {
    00082     s.addIdentifiedLink(pObject, m_hintID);
    00083   }
    00085   void writeObject  (const ContainedObject* pObject, StreamBuffer& s)  const    {
    00086     s.addContainedLink(pObject, m_hintID, m_linkID);
    00087   }
    00089   DataObject* readObject   (const DataObject* /* pObject */, StreamBuffer& s)  const   {
    00090     DataObject* pObj = 0;
    00091     s.getIdentifiedLink(pObj, m_hintID);
    00092     return pObj;
    00093   }
    00095   ContainedObject* readObject(const ContainedObject* /* pObject */, StreamBuffer& s)  const    {
    00096     ContainedObject* pObj = 0;
    00097     s.getContainedLink(pObj, m_hintID, m_linkID);
    00098     return pObj;
    00099   }
    00100   void setObjectType(const ContainedObject* /* pobj */) const {
    00101     m_type = CONTAINEDOBJECT;
    00102   }
    00103   void setObjectType(const DataObject* /* pobj */)  const {
    00104     m_type = DATAOBJECT;
    00105   }
    00106
    00108   const std::string &path () const;
    00109
    00110 public:
    00111   int objectType()  const {
    00112     return m_type;
    00113   }
    00115   void set(DataObject* pObj, long hint_id, long link_id);
    00116
    00117 };
    00118 #endif // KERNEL_SMARTREFBASE_H