Go to the documentation of this file.00001 #include "CondCore/ORA/interface/Container.h"
00002 #include "DatabaseContainer.h"
00003 #include "ClassUtils.h"
00004
00005 ora::ContainerIterator::ContainerIterator( Handle<IteratorBuffer>& iteratorBuffer ):
00006 m_buffer( iteratorBuffer ){
00007 }
00008
00009 ora::ContainerIterator::ContainerIterator( const ContainerIterator& rhs ):
00010 m_buffer( rhs.m_buffer ){
00011 }
00012
00013 ora::ContainerIterator::~ContainerIterator(){
00014 }
00015
00016 ora::ContainerIterator& ora::ContainerIterator::operator=( const ContainerIterator& rhs ){
00017 if(this != &rhs ) m_buffer = rhs.m_buffer;
00018 return *this;
00019 }
00020
00021 void ora::ContainerIterator::reset(){
00022 m_buffer->reset();
00023 }
00024
00025 bool ora::ContainerIterator::next(){
00026 return m_buffer->next();
00027 }
00028
00029 int ora::ContainerIterator::itemId(){
00030 return m_buffer->itemId();
00031 }
00032
00033 ora::Object ora::ContainerIterator::getItem(){
00034 return Object( m_buffer->getItem(), m_buffer->type() );
00035 }
00036
00037 boost::shared_ptr<void> ora::ContainerIterator::getItemAsType( const std::type_info& asTypeInfo ){
00038 Reflex::Type castType = ClassUtils::lookupDictionary( asTypeInfo );
00039 void* ptr = m_buffer->getItemAsType( castType );
00040 return boost::shared_ptr<void>( ptr, RflxDeleter( m_buffer->type() ) );
00041 }
00042
00043 ora::Container::Container( Handle<DatabaseContainer>& dbContainer ):
00044 m_dbContainer( dbContainer ){
00045 }
00046
00047 ora::Container::Container( const Container& rhs ):
00048 m_dbContainer( rhs.m_dbContainer ){
00049 }
00050
00051 ora::Container::~Container(){
00052 }
00053
00054 ora::Container& ora::Container::operator=( const Container& rhs ){
00055 if(this != &rhs ) m_dbContainer = rhs.m_dbContainer;
00056 return *this;
00057 }
00058
00059 int ora::Container::id(){
00060 return m_dbContainer->id();
00061 }
00062
00063 const std::string& ora::Container::name(){
00064 return m_dbContainer->name();
00065 }
00066
00067 const std::string& ora::Container::className(){
00068 return m_dbContainer->className();
00069 }
00070
00071 const std::string& ora::Container::mappingVersion(){
00072 return m_dbContainer->mappingVersion();
00073 }
00074
00075 size_t ora::Container::size(){
00076 return m_dbContainer->size();
00077 }
00078
00079 ora::ContainerIterator ora::Container::iterator(){
00080 Handle<IteratorBuffer> buff = m_dbContainer->iteratorBuffer();
00081 return ContainerIterator( buff );
00082 }
00083
00084 void ora::Container::extendSchema( const std::type_info& typeInfo ){
00085 Reflex::Type type = ClassUtils::lookupDictionary( typeInfo );
00086 m_dbContainer->extendSchema( type );
00087 }
00088
00089 ora::Object ora::Container::fetchItem(int itemId){
00090 return Object( m_dbContainer->fetchItem(itemId), m_dbContainer->type() );
00091 }
00092
00093 boost::shared_ptr<void> ora::Container::fetchItemAsType(int itemId,
00094 const std::type_info& asTypeInfo){
00095 Reflex::Type asType = ClassUtils::lookupDictionary( asTypeInfo );
00096 void* ptr = m_dbContainer->fetchItemAsType(itemId, asType );
00097 if(!ptr) return boost::shared_ptr<void>();
00098 return boost::shared_ptr<void>( ptr, RflxDeleter( m_dbContainer->type() ) );
00099 }
00100
00101 int ora::Container::insertItem( const Object& data ){
00102 const Reflex::Type& objType = data.type();
00103 if(!objType){
00104 throwException("Object class has not been found in the dictionary.",
00105 "Container::insertItem");
00106 }
00107 return m_dbContainer->insertItem( data.address(), objType );
00108 }
00109
00110 int ora::Container::insertItem( const void* data,
00111 const std::type_info& typeInfo ){
00112 Reflex::Type type = ClassUtils::lookupDictionary( typeInfo );
00113 return m_dbContainer->insertItem( data, type );
00114 }
00115
00116 void ora::Container::updateItem( int itemId,
00117 const Object& data ){
00118 const Reflex::Type& objType = data.type();
00119 if(!objType){
00120 throwException("Object class has not been found in the dictionary.",
00121 "Container::updateItem");
00122 }
00123 return m_dbContainer->updateItem( itemId, data.address(), objType );
00124 }
00125
00126 void ora::Container::updateItem( int itemId,
00127 const void* data,
00128 const std::type_info& typeInfo ){
00129 Reflex::Type type = ClassUtils::lookupDictionary( typeInfo );
00130 m_dbContainer->updateItem( itemId, data, type );
00131 }
00132
00133 void ora::Container::erase( int itemId ){
00134 m_dbContainer->erase(itemId );
00135 }
00136
00137 void ora::Container::flush(){
00138 m_dbContainer->flush();
00139 }
00140
00141 void ora::Container::setItemName( const std::string& name,
00142 int itemId ){
00143 m_dbContainer->setItemName( name, itemId );
00144 }
00145
00146 bool ora::Container::getNames( std::vector<std::string>& destination ){
00147 return m_dbContainer->getNames( destination );
00148 }
00149
00150