CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/CondCore/ORA/src/DatabaseContainer.h

Go to the documentation of this file.
00001 #ifndef INCLUDE_ORA_DATABASECONTAINER_H
00002 #define INCLUDE_ORA_DATABASECONTAINER_H
00003 
00004 #include "CondCore/ORA/interface/Handle.h"
00005 #include "RelationalOperation.h"
00006 //
00007 #include <string>
00008 #include <vector>
00009 #include <memory>
00010 #include <typeinfo>
00011 
00012 namespace Reflex {
00013   class Type;
00014 }
00015 
00016 namespace ora {
00017 
00018   class IDatabaseSchema;
00019   class ContainerSchema;
00020   class DatabaseSession;
00021   class ContainerUpdateTable;
00022   class WriteBuffer;
00023   class UpdateBuffer;
00024   class ReadBuffer;
00025   class DeleteBuffer;
00026 
00027   class IteratorBuffer{
00028     public:
00029     IteratorBuffer( ContainerSchema& schema, ReadBuffer& buffer );
00030 
00031     ~IteratorBuffer();
00032 
00033     void reset();
00034 
00035     bool next();
00036 
00037     void* getItem();
00038 
00039     void* getItemAsType( const Reflex::Type& type );
00040 
00041     int itemId();
00042 
00043     const Reflex::Type& type();
00044       
00045     private:
00046     SelectOperation m_query;
00047     int m_itemId;
00048     ReadBuffer& m_readBuffer;
00049   };
00050   
00051   class DatabaseContainer {
00052     
00053     public:
00054     DatabaseContainer( int contId, const std::string& containerName, const std::string& className,
00055                        unsigned int containerSize, DatabaseSession& session );
00056 
00057     DatabaseContainer( int contId, const std::string& containerName, const Reflex::Type& containerType,
00058                        DatabaseSession& session );                  
00059     
00060     virtual ~DatabaseContainer();
00061 
00062     int id();
00063 
00064     const std::string& name();
00065 
00066     const std::string& className();
00067 
00068     const Reflex::Type& type();
00069 
00070     const std::string& mappingVersion();
00071 
00072     size_t size();
00073 
00074     void create();
00075 
00076     void drop();
00077 
00078     void extendSchema( const Reflex::Type& dependentType );
00079 
00080     void setAccessPermission( const std::string& principal, bool forWrite );
00081 
00082     Handle<IteratorBuffer> iteratorBuffer();
00083 
00084     bool lock();
00085 
00086     bool isLocked();
00087 
00088     void* fetchItem(int itemId);
00089 
00090     void* fetchItemAsType(int itemId, const Reflex::Type& asType);
00091 
00092     int insertItem( const void* data, const Reflex::Type& type );
00093     
00094     void updateItem( int itemId, const void* data, const Reflex::Type& type );    
00095 
00096     void erase( int itemId );
00097     
00098     void flush();
00099 
00100     void setItemName( const std::string& name, int itemId );
00101 
00102     bool getNames( std::vector<std::string>& destination );
00103 
00104     private:
00105     IDatabaseSchema& m_dbSchema;
00106     std::auto_ptr<ContainerSchema> m_schema;
00107     std::auto_ptr<WriteBuffer> m_writeBuffer;
00108     std::auto_ptr<UpdateBuffer> m_updateBuffer;
00109     std::auto_ptr<ReadBuffer>   m_readBuffer;
00110     std::auto_ptr<DeleteBuffer> m_deleteBuffer;
00111     Handle<IteratorBuffer> m_iteratorBuffer;
00112     size_t m_size;
00113     ContainerUpdateTable& m_containerUpdateTable;
00114     bool m_lock;
00115   };
00116 
00117 }
00118 
00119 #endif