#include <IOPool/CMSSealPlugins/plugins/PrimitivesContainerStreamer.h>
Public Member Functions | |
BlobReader (const ROOT::Reflex::Type &type) | |
Constructor. | |
void | read (const coral::Blob &blobData, void *containerAddress) const |
Reads an object from a Blob and returns the starting address of the object. | |
virtual | ~BlobReader () |
Empty destructor. | |
Private Attributes | |
ROOT::Reflex::Type | m_type |
The type. |
Definition at line 31 of file PrimitivesContainerStreamer.h.
cond::BlobReader::BlobReader | ( | const ROOT::Reflex::Type & | type | ) |
cond::BlobReader::~BlobReader | ( | ) | [virtual] |
Reads an object from a Blob and returns the starting address of the object.
Definition at line 73 of file PrimitivesContainerStreamer.cc.
References Exception, m_type, and v.
00075 { 00076 //std::cout<<"cond::BlobReader::read"<<std::endl; 00077 const void * srcstartingAddress=blobData.startingAddress(); 00078 //std::cout<<"srcstartingAddress "<<srcstartingAddress<<std::endl; 00079 //std::cout<<"dest Address "<<containerAddress<<std::endl; 00080 long bsize=blobData.size(); 00081 if(bsize==0){ 00082 //std::cout<<"empty blob to read"<<std::endl; 00083 return; 00084 } 00085 //std::cout<<"blob size "<<bsize<<std::endl; 00086 ROOT::Reflex::Member clearMethod = m_type.MemberByName( "clear" ); 00087 if ( ! clearMethod ) 00088 throw cond::Exception( "BlobReader::read Could not retrieve the clear method of the container" ); 00089 ROOT::Reflex::Object containerObject( m_type, containerAddress ); 00090 // Clear the container 00091 clearMethod.Invoke( containerObject ); 00092 //const ROOT::Reflex::Type signature(); 00093 ROOT::Reflex::Member resizeMethod = m_type.MemberByName( "resize",ROOT::Reflex::Type::ByName("void (size_t)") ); 00094 if ( ! resizeMethod ) 00095 throw cond::Exception( "BlobReader::read Could not retrieve the resize method of the container" ); 00096 // resize the container 00097 //size_t nargs=m_type.TemplateArgumentSize(); 00098 //std::cout<<"template arguments to vector "<<nargs<<std::endl; 00099 size_t elementSize=m_type.TemplateArgumentAt(0).SizeOf(); 00100 //std::cout<<"elementSize "<<elementSize<<std::endl; 00101 std::vector<void *> v(1); 00102 size_t containerSize = bsize / elementSize; 00103 //std::cout<<" container size "<<containerSize<<std::endl; 00104 //std::cout<<" container size address "<<(void*)(&containerSize)<<std::endl; 00105 /*for(size_t i=0; i<containerSize; ++i){ 00106 containerObject.Invoke("push_back", 0); //hack!! 00107 } 00108 */ 00109 v[0] = (void*)(&containerSize); 00110 //int temp=0; 00111 //v[1] = (void*)(&temp); 00112 //v.push_back((void*)(&containerSize)); 00113 //std::cout<<resizeMethod.Name()<<std::endl; 00114 resizeMethod.Invoke( containerObject,v ); 00115 // Create an iterator 00116 ROOT::Reflex::Member beginMethod = m_type.MemberByName( "begin" ); 00117 if ( ! beginMethod ) 00118 throw cond::Exception( "BlobReader::read No begin method is defined for the container" ); 00119 ROOT::Reflex::Object iteratorObject = beginMethod.Invoke( ROOT::Reflex::Object( m_type, const_cast< void * > ( containerAddress ) ) ); 00120 ROOT::Reflex::Type iteratorType = beginMethod.TypeOf().ReturnType(); 00121 //get first element address 00122 ROOT::Reflex::Member dereferenceMethod = iteratorType.MemberByName( "operator*" ); 00123 if ( ! dereferenceMethod ) 00124 throw cond::Exception( "BlobReader::read Could not retrieve the dereference method of the container's iterator" ); 00125 void* elementAddress = dereferenceMethod.Invoke( iteratorObject ).Address(); 00126 ::memcpy( elementAddress, srcstartingAddress, (size_t)bsize); 00127 //std::cout<<"memcpy"<<std::endl; 00128 iteratorObject.Destruct(); 00129 }
ROOT::Reflex::Type cond::BlobReader::m_type [private] |