CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_8_patch3/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   *persistentSize = arraySize;
00071 }
00072 
00073 ora::PVectorReader::PVectorReader(const Reflex::Type& objectType,
00074                                   MappingElement& mapping,
00075                                   ContainerSchema& contSchema ):
00076   m_reader( objectType, mapping, contSchema ){
00077 }
00078 
00079 ora::PVectorReader::~PVectorReader(){
00080 }
00081 
00082 bool ora::PVectorReader::build( DataElement& offset,
00083                                 IRelationalData& relationalData ){
00084   return m_reader.build( offset, relationalData );
00085 }
00086 
00087 void ora::PVectorReader::select( int oid ){
00088   m_reader.select( oid );
00089 }
00090 
00091 void ora::PVectorReader::setRecordId( const std::vector<int>& identity ){
00092   m_reader.setRecordId( identity );
00093 }
00094 
00095 
00096 void ora::PVectorReader::read( void* destinationData ) {
00097   m_reader.read( destinationData );
00098 }
00099 
00100 void ora::PVectorReader::clear(){
00101   m_reader.clear();
00102 }
00103 
00104 ora::PVectorStreamer::PVectorStreamer( const Reflex::Type& objectType,
00105                                        MappingElement& mapping,
00106                                        ContainerSchema& contSchema ):
00107   m_objectType( objectType ),
00108   m_mapping( mapping ),
00109   m_schema( contSchema ){
00110 }
00111 
00112 ora::PVectorStreamer::~PVectorStreamer(){
00113 }
00114 
00115 ora::IRelationalWriter* ora::PVectorStreamer::newWriter(){
00116   return new PVectorWriter( m_objectType, m_mapping, m_schema );
00117 }
00118 
00119 ora::IRelationalUpdater* ora::PVectorStreamer::newUpdater(){
00120   return new PVectorUpdater( m_objectType, m_mapping, m_schema );
00121 }
00122 
00123 ora::IRelationalReader* ora::PVectorStreamer::newReader(){
00124   return new PVectorReader( m_objectType, m_mapping, m_schema );
00125 }