10 #include "TBufferFile.h"
11 #include "Reflex/Reflex.h"
12 #include "Cintex/Cintex.h"
17 #define PRIMITIVE(x) { \
19 reinterpret_cast<WriteArrayFn_t>( \
20 (void (TBuffer::*)(const x*, Int_t))&TBuffer::WriteFastArray), \
21 reinterpret_cast<ReadArrayFn_t>( \
22 (void (TBuffer::*)(x*, Int_t))&TBuffer::ReadFastArray) \
26 const std::type_info &
type;
31 {
return type == other; }
54 : m_arraySize(0), m_class(0), m_primitive(0)
56 static bool cintexInitialized =
false;
57 if (!cintexInitialized) {
58 cintexInitialized =
true;
59 ROOT::Cintex::Cintex::Enable();
64 type = type.FinalType();
76 const std::type_info &typeInfo = type.TypeInfo();
77 m_class = TClass::GetClass(typeInfo);
80 "No ROOT class registered for " + type.Name());
81 }
else if (type.IsFundamental()) {
84 "Only arrays of primitive types supported. "
85 "Please to not use a Blob for this member.");
91 "Cannot handle primitive type " + type.Name());
94 "Cannot handle C++ type " + type.Name());
104 #include <boost/bind.hpp>
106 inline char * reallocInBlob( boost::shared_ptr<coral::Blob> theBlob,
char*
p,
size_t newsize,
size_t oldsize) {
108 theBlob->resize(newsize);
109 return (
char*)theBlob->startingAddress();
120 "not of actual class.");
122 boost::shared_ptr<coral::Blob> theBlob(
new coral::Blob );
127 TBufferFile buffer(TBufferFile::kWrite);
135 buffer.StreamObject(const_cast<void*>(addr), theType.
m_class);
137 Int_t
size = buffer.Length();
139 theBlob->resize(size);
140 void *startingAddress = theBlob->startingAddress();
141 std::memcpy(startingAddress, buffer.Buffer(),
size);
150 const void *startingAddress = blobData.startingAddress();
151 size_t size = blobData.size();
155 TBufferFile buffer(TBufferFile::kRead, size,
156 const_cast<void*>(startingAddress), kFALSE);
165 buffer.StreamObject(addr, theType.
m_class);
std::size_t m_arraySize
length of the plain C array (zero otherwise)
TClass * m_class
The class as seen by the ROOT streaming services.
void read(const coral::Blob &blobData, void *addressOfContainer, Reflex::Type const &classDictionary)
Reads an object from a Blob and fills-in the container.
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
unsigned int m_primitive
the primitive C++ type if m_class is unset
const std::type_info & type
TBufferBlobTypeInfo(const Reflex::Type &type)
virtual ~TBufferBlobStreamingService()
boost::shared_ptr< coral::Blob > write(const void *addressOfInputData, Reflex::Type const &classDictionary, bool useCompression=false)
void(TBuffer::* ReadArrayFn_t)(void *obj, Int_t n)
static const std::size_t nPrimitives
TBufferBlobStreamingService()
ReadArrayFn_t readArrayFn
WriteArrayFn_t writeArrayFn
void(TBuffer::* WriteArrayFn_t)(const void *obj, Int_t n)
tuple size
Write out results.
struct Primitive primitives[]
bool operator==(const std::type_info &other) const