CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/CondCore/ORA/src/PVectorStreamer.cc

Go to the documentation of this file.
00001 #include "CondCore/ORA/interface/Exception.h"
00002 #include "PVectorStreamer.h"
00003 #include "ArrayCommonImpl.h"
00004 #include "IArrayHandler.h"
00005 
00006 ora::PVectorWriter::PVectorWriter( const Reflex::Type& objectType,
00007                                    MappingElement& mapping,
00008                                    ContainerSchema& contSchema ):
00009   m_writer( objectType, mapping, contSchema ){
00010 }
00011 
00012 ora::PVectorWriter::~PVectorWriter(){
00013 }
00014 
00015 bool ora::PVectorWriter::build( DataElement& offset,
00016                                 IRelationalData& data,
00017                                 RelationalBuffer& operationBuffer ){
00018   return m_writer.build( offset, data, operationBuffer );
00019 }
00020 
00021 void ora::PVectorWriter::setRecordId( const std::vector<int>& identity ){
00022   m_writer.setRecordId( identity );
00023 }
00024       
00025 void ora::PVectorWriter::write( int oid,
00026                                 const void* inputData )
00027 {
00028   m_writer.write( oid, inputData );
00029 }
00030 
00031 ora::PVectorUpdater::PVectorUpdater(const Reflex::Type& objectType,
00032                                     MappingElement& mapping,
00033                                     ContainerSchema& contSchema ):
00034   m_buffer(0),
00035   m_writer( objectType, mapping, contSchema ){
00036 }
00037 
00038 ora::PVectorUpdater::~PVectorUpdater(){
00039 }
00040 
00041 bool ora::PVectorUpdater::build( DataElement& offset,
00042                                  IRelationalData& relationalData,
00043                                  RelationalBuffer& operationBuffer){
00044   m_buffer = &operationBuffer;
00045   return m_writer.build( offset, relationalData, operationBuffer );
00046 }
00047 
00048 void ora::PVectorUpdater::setRecordId( const std::vector<int>& identity ){
00049   m_writer.setRecordId( identity );
00050 }
00051 
00052 void ora::PVectorUpdater::update( int oid,
00053                                   const void* data ){
00054   if(!m_writer.dataElement()){
00055     throwException("The streamer has not been built.",
00056                    "PVectorUpdater::update");
00057   }
00058   
00059   void* arrayData = m_writer.dataElement()->address( data );
00060   IArrayHandler& arrayHandler = *m_writer.arrayHandler();
00061   
00062   size_t arraySize = arrayHandler.size(arrayData);
00063   size_t persistentSize = arrayHandler.persistentSize(arrayData);
00064   if(persistentSize>arraySize){
00065     deleteArrayElements( m_writer.mapping(), oid, arraySize, *m_buffer );
00066   }
00067   else if(persistentSize<arraySize) {
00068     m_writer.write( oid, data );
00069   }
00070 }
00071 
00072 ora::PVectorReader::PVectorReader(const Reflex::Type& objectType,
00073                                   MappingElement& mapping,
00074                                   ContainerSchema& contSchema ):
00075   m_reader( objectType, mapping, contSchema ){
00076 }
00077 
00078 ora::PVectorReader::~PVectorReader(){
00079 }
00080 
00081 bool ora::PVectorReader::build( DataElement& offset,
00082                                 IRelationalData& relationalData ){
00083   return m_reader.build( offset, relationalData );
00084 }
00085 
00086 void ora::PVectorReader::select( int oid ){
00087   m_reader.select( oid );
00088 }
00089 
00090 void ora::PVectorReader::setRecordId( const std::vector<int>& identity ){
00091   m_reader.setRecordId( identity );
00092 }
00093 
00094 
00095 void ora::PVectorReader::read( void* destinationData ) {
00096   m_reader.read( destinationData );
00097 }
00098 
00099 void ora::PVectorReader::clear(){
00100   m_reader.clear();
00101 }
00102 
00103 ora::PVectorStreamer::PVectorStreamer( const Reflex::Type& objectType,
00104                                        MappingElement& mapping,
00105                                        ContainerSchema& contSchema ):
00106   m_objectType( objectType ),
00107   m_mapping( mapping ),
00108   m_schema( contSchema ){
00109 }
00110 
00111 ora::PVectorStreamer::~PVectorStreamer(){
00112 }
00113 
00114 ora::IRelationalWriter* ora::PVectorStreamer::newWriter(){
00115   return new PVectorWriter( m_objectType, m_mapping, m_schema );
00116 }
00117 
00118 ora::IRelationalUpdater* ora::PVectorStreamer::newUpdater(){
00119   return new PVectorUpdater( m_objectType, m_mapping, m_schema );
00120 }
00121 
00122 ora::IRelationalReader* ora::PVectorStreamer::newReader(){
00123   return new PVectorReader( m_objectType, m_mapping, m_schema );
00124 }