![]() |
![]() |
#include <IOPool/CMSSealPlugins/plugins/PrimitivesContainerStreamer.h>
Public Member Functions | |
BlobWriter (const ROOT::Reflex::Type &type) | |
Constructor. | |
const coral::Blob & | write (const void *addressOfInputData) |
Streams an object an returns by constant reference the underlying blob. | |
virtual | ~BlobWriter () |
Empty destructor. | |
Private Attributes | |
coral::Blob | m_blob |
The blob data. | |
ROOT::Reflex::Type | m_type |
The type. |
Definition at line 10 of file PrimitivesContainerStreamer.h.
cond::BlobWriter::BlobWriter | ( | const ROOT::Reflex::Type & | type | ) | [explicit] |
cond::BlobWriter::~BlobWriter | ( | ) | [virtual] |
const coral::Blob & cond::BlobWriter::write | ( | const void * | addressOfInputData | ) |
Streams an object an returns by constant reference the underlying blob.
Definition at line 18 of file PrimitivesContainerStreamer.cc.
References Exception, m_blob, and m_type.
00019 { 00020 // std::cout<<"cond::BlobReader::write"<<std::endl; 00021 ROOT::Reflex::Object theContainer( m_type, const_cast<void*>( addressOfInputData ) ); 00022 //get the container size 00023 ROOT::Reflex::Member sizeMethod = m_type.MemberByName( "size" ); 00024 if ( ! sizeMethod ) 00025 throw cond::Exception( "BlobWriter::write No size method is defined for the container" ); 00026 ROOT::Reflex::Object ret = sizeMethod.Invoke(theContainer); 00027 if( !ret.TypeOf() || !ret.Address() ) 00028 throw cond::Exception( "BlobWriter::write Could not invoke the size method on the container" ); 00029 size_t containerSize = *(static_cast<size_t*>(ret.Address())); 00030 if(containerSize==0){ 00031 //std::cout<<"empty container nothing to write"<<std::endl; 00032 return m_blob; 00033 } 00034 // std::cout<<"container size "<<containerSize<<std::endl; 00035 //get the element size 00036 //size_t nargs=m_type.TemplateArgumentSize(); 00037 //std::cout<<"template arguments to vector "<<nargs<<std::endl; 00038 size_t elementSize=m_type.TemplateArgumentAt(0).SizeOf(); 00039 //std::cout<<"elementSize "<<elementSize<<std::endl; 00040 ROOT::Reflex::Member beginMethod = m_type.MemberByName( "begin" ); 00041 if ( ! beginMethod ) 00042 throw cond::Exception( "BlobWriter::write No begin method is defined for the container" ); 00043 ROOT::Reflex::Type iteratorType = beginMethod.TypeOf().ReturnType(); 00044 ROOT::Reflex::Member dereferenceMethod = iteratorType.MemberByName( "operator*" ); 00045 if ( ! dereferenceMethod ) 00046 throw cond::Exception( "BlobWriter::write Could not retrieve the dereference method of the container's iterator" ); 00047 //size_t elementSize = dereferenceMethod.TypeOf().ReturnType().SizeOf(); 00048 // Create an iterator 00049 ROOT::Reflex::Object iteratorObject = beginMethod.Invoke( ROOT::Reflex::Object( m_type, const_cast< void * > ( addressOfInputData ) ) ); 00050 //get first element address 00051 void* elementAddress = dereferenceMethod.Invoke( iteratorObject ).Address(); 00052 m_blob.resize( containerSize * elementSize ); 00053 void* startingAddress = m_blob.startingAddress(); 00054 //std::cout<<"dest Address "<<elementAddress <<std::endl; 00055 //std::cout<<"src address"<<addressOfInputData <<std::endl; 00056 ::memcpy( startingAddress, elementAddress, containerSize*elementSize ); 00057 iteratorObject.Destruct(); 00058 //std::cout<<"new blob size "<<m_blob.size()<<std::endl; 00059 return m_blob; 00060 }
coral::Blob cond::BlobWriter::m_blob [private] |
ROOT::Reflex::Type cond::BlobWriter::m_type [private] |