8#include "CoralBase/Attribute.h"
9#include "CoralBase/AttributeListSpecification.h"
10#include "CoralBase/AttributeListException.h"
11#include "CoralBase/Blob.h"
13#include "TBufferFile.h"
20 const std::string& name,
21 const IInterface* parent) :
24 declareInterface<Blob2ToolConstants>(
this);
29 msg(MSG::DEBUG) <<
"Initializing..." <<
endmsg;
30 return StatusCode::SUCCESS;
36 coral::AttributeListSpecification* spec =
new coral::AttributeListSpecification();
38 spec->extend(
"clsname",
"string");
39 spec->extend(
"version",
"unsigned int");
40 spec->extend(
"blobVersion",
"unsigned int");
41 spec->extend(
"Constants",
"blob");
44 auto attrList = std::make_unique<coral::AttributeList>(*spec);
50 (*attrList)[
"clsname"].data<std::string>()=
tc->clsname();
51 (*attrList)[
"version"].data<
unsigned int>()=(
unsigned int)
tc->version();
52 (*attrList)[
"blobVersion"].data<
unsigned int>()=(
unsigned int)0;
54 coral::Blob& blob=(*attrList)[
"Constants"].data<coral::Blob>();
57 TClass* klass = TClass::GetClass (
"std::map<std::string, CaloRec::Arrayrep>");
59 msg( MSG::ERROR) <<
"Can't find TClass std::map<std::string, CaloRec::Arrayrep>" <<
endmsg;
63 msg(MSG::DEBUG) <<
"Got TClass std::map<std::string, CaloRec::Arrayrep>" <<
endmsg;
65 TBufferFile buf (TBuffer::kWrite);
67 if (buf.WriteObjectAny (&
tc->map(), klass) != 1) {
68 msg(MSG::ERROR) <<
"Failed to stream CaloRec::ToolConstants::Maptype " <<
endmsg;
72 blob.resize(buf.Length());
73 void* adr = blob.startingAddress();
74 memcpy(adr,buf.Buffer(),buf.Length());
75 return attrList.release();
81 std::unique_ptr<T>
map;
86 const unsigned blobVersion=attrList[
"blobVersion"].data<
unsigned int>();
87 const coral::Blob& blob = attrList[
"Constants"].data<coral::Blob>();
90 msg(MSG::ERROR) <<
"Can't interpret BLOB version " << blobVersion <<
endmsg;
91 return StatusCode::FAILURE;
94 TClass* klass = TClass::GetClass (
"std::map<std::string, CaloRec::Arrayrep>");
96 msg(MSG::ERROR) <<
"Can't find TClass std::map<std::string, CaloRec::Arrayrep>" <<
endmsg;
97 return StatusCode::FAILURE;
100 msg(MSG::DEBUG) <<
"Got TClass std::map<std::string, CaloRec::Arrayrep>" <<
endmsg;
104 TBufferFile buf (TBuffer::kRead, blob.size(), blob_start,
false);
105 map.reset( (T*)buf.ReadObjectAny (klass) );
106 }
catch (coral::AttributeListException &e) {
108 return StatusCode::FAILURE;
111 T::const_iterator it=
map->begin();
112 T::const_iterator it_e=
map->end();
113 for (;it!=it_e;++it) {
114 tc.setrep(it->first,it->second);
116 return StatusCode::SUCCESS;
121 const uint32_t hash32=(uint32_t)(hash64 & 0xFFFFFFFF);
char data[hepevt_bytes_allocation_ATLAS]
Define macros for attributes used to control the static checker.
#define ATLAS_THREAD_SAFE
A crc-64 implementation, using pclmul where possible.
uint64_t crc64(const CRCTable &table, const char *data, size_t data_len)
Find the CRC-64 of a string,.