CkptContainer.h

Go to the documentation of this file.
00001 #ifndef CKPTCONTAINER_H_
00002 #define CKPTCONTAINER_H_
00003 
00004 #include <memory>
00005 #include <saAis.h>
00006 #include <saCkpt.h>
00007 #include "CkptObject.h"
00008 #include "CkptRawDAO.h"
00009 
00014 enum CkptRetentionPolicy { 
00015     CKPT_RETAIN, 
00016     CKPT_RELEASE 
00017     };
00018 
00027 class CkptContainer {
00028  public:
00039  CkptContainer(std::string containerName,
00040                unsigned long maxObjects,
00041                unsigned long maxObjectSize,
00042                CkptRetentionPolicy rPolicy=CKPT_RELEASE);
00043 
00058  ~CkptContainer();
00059 
00067  unsigned long size();
00068 
00089  CkptObject* get(CkptObjectKey *key);
00090  
00107  CkptObject* get(CkptObjectKey &key);
00108 
00120  CkptRC persist(CkptObject *obj, bool overwriteExisting=true);
00121 
00129  CkptRC remove(CkptObject *obj);
00130 
00135  CkptRC commit(CkptObject *obj);
00136 
00145  bool isValid() { return _valid; }
00146 
00159  CkptRC setRetentionPolicy(CkptRetentionPolicy rPolicy);
00160   
00161 private:
00162  std::string             _containerName;    
00163  SaNameT                 _checkpointName;   
00164  SaCkptHandleT           _serviceHandle;    
00165  SaCkptCheckpointHandleT _checkpointHandle; 
00166  unsigned long           _maxObjectSize;    
00167  bool                    _valid;            
00168  DAOInterfaceFactory*    _daoFactory;       
00169 };
00170 
00175 template <class T>
00176 class CkptSimpleContainer : public CkptContainer {
00177 public:
00178    CkptSimpleContainer(std::string containerName,
00179                        unsigned long maxObjects,
00180                        unsigned long maxObjectSize,
00181                        CkptRetentionPolicy rPolicy=CKPT_RELEASE)
00182        : CkptContainer(containerName,maxObjects,maxObjectSize, rPolicy) { }
00183 
00184     T* get(CkptObjectKey *key) {
00185         return (T*)CkptContainer::get(key);
00186     }
00187     T* get(CkptObjectKey &key) {
00188         return (T*)CkptContainer::get(key);
00189     }
00190 };
00191 
00192 #endif /*CKPTCONTAINER_H_*/
00193 

Generated on Fri Apr 27 17:20:01 2007 for aiscoal by  doxygen 1.5.2