Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

DbPersistent.h

Go to the documentation of this file.
00001 //====================================================================
00002 //      DbPersistent definition
00003 //--------------------------------------------------------------------
00004 //
00005 //      Package    : System ( The LHCb Offline System)
00006 //
00007 //  Description: Definition of abstract persistent object
00008 //
00009 //      Author     : M.Frank
00010 //  History    :
00011 // +---------+----------------------------------------------+---------
00012 // |    Date |                 Comment                      | Who     
00013 // +---------+----------------------------------------------+---------
00014 // | 11/07/99| Initial version                              | MF
00015 // +---------+----------------------------------------------+---------
00016 //====================================================================
00017 #ifndef DBCNV_DBSVC_DBPERSISTENT_H
00018 #define DBCNV_DBSVC_DBPERSISTENT_H 1
00019 
00020 // Forward declarations
00021 class StreamBuffer;
00022 class DbLink;
00023 class DbObject;
00024 class DbTypeInfo;
00025 class DbContainer;
00026 class DbPersistent;
00027 class DbPersistent;
00028 template <class T> class dbHandle;
00029 template <class T> class dbVarray;
00030 //template <> class dbHandle<DbLink>;
00031 //template <> class dbHandle<DbContainer>;
00032 
00049 class DbPersistentGuard  {
00050   friend class DbObject;
00051 protected:
00052   virtual ~DbPersistentGuard()   {
00053   }
00054 public:
00056   virtual unsigned long addRef() const = 0;
00058   virtual unsigned long release() const = 0;
00060   virtual unsigned char type()  const = 0;
00062   virtual void setContainer (const dbHandle<DbContainer>& cntH) = 0;
00064   virtual dbHandle<DbContainer>& container() const = 0;
00066   virtual void setPersistent (DbPersistent* cntH) = 0;
00068   virtual unsigned long* oid()  const   = 0;
00070   virtual DbPersistent* persistent() const = 0;
00072   virtual void setObjectSize(long siz) = 0;
00074   virtual long objectSize()  const = 0;
00076   virtual void setSize(long siz) = 0;
00078   virtual long size()  const = 0;
00080   virtual dbVarray< dbHandle<DbLink> >& links() const = 0;
00082   virtual StreamBuffer& objBuffer() const = 0;
00084   virtual StreamBuffer& linkBuffer() const = 0;
00085 };
00086 
00110 class DbPersistent    {
00111 protected:
00112 public:
00114   DbPersistent();
00116   virtual ~DbPersistent();
00117 
00118   // Access proper type information
00119   virtual const DbTypeInfo* typeInfo() const = 0;
00121   virtual bool getBuffer(long start, long length, StreamBuffer& buff) = 0;
00123   virtual bool setBuffer(long start, long length, const StreamBuffer& buff) = 0;
00124 
00126   virtual void release();
00128   virtual bool load(DbObject* pObject);
00130   virtual bool save(const DbObject* pObject);
00132   static DbPersistentGuard* createGuard();
00134   static DbPersistentGuard* guard(DbObject* pObj);
00136   static const DbPersistentGuard* guard(const DbObject* pObj);
00138   static void setGuard(DbObject* pObj, DbPersistentGuard* pGuard);
00140   static DbPersistent* persistent(const DbObject* pObj);
00142   static DbObject* create(const DbTypeInfo* type, DbPersistent* persistent, const dbHandle<DbContainer>& cntH);
00144   static DbObject* load (DbPersistent* persistent, const dbHandle<DbContainer>& cntH);
00146   static void* allocate (const dbHandle<DbContainer>& nearH, const DbTypeInfo& type );
00147 };
00148 
00149 // We cannot include the implementation while processing the ddl file!
00150 #if !defined(ooddl) && !defined(__CINT__)
00151 #include "GaudiDb/DbPersistent.icpp"
00152 #endif
00153 
00154 #endif // DBCNV_DBSVC_DBPERSISTENT_H

Generated at Wed Nov 21 12:22:20 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000