14 const coral::Blob* blob)
68 if(&other ==
this) {
return *
this;}
86 uint32_t objSizeUint32,
90 const std::string& author,
91 const std::string& comment,
96 const uint32_t dataSizeByte = (
getHdrSize()+objSizeUint32*nObjs) *
sizeof(uint32_t);
99 uint32_t commentSizeChar(0);
100 if(!author.empty() || !comment.empty() || timeStamp){
101 commentSizeChar += author.size()+comment.size()+
sizeof(uint64_t) + 2;
103 commentSizeChar += (commentSizeChar %
sizeof(uint32_t)) ?
104 (
sizeof(uint32_t)-(commentSizeChar %
sizeof(uint32_t))) : 0;
108 const uint32_t blobSizeInBytes = dataSizeByte+commentSizeChar;
112 reinterpret_cast<uint16_t*
>(
getBlobStart())[0] = objType;
113 reinterpret_cast<uint16_t*
>(
getBlobStart())[1] = objVersion;
124 if(!timeStamp) timeStamp = ::time(
nullptr);
125 uint8_t* pChar =
reinterpret_cast<uint8_t*
> (
getBlobStart()+dataSizeByte/
sizeof(uint32_t));
127 std::string::const_iterator iStr = author.begin();
128 for(; iStr!=author.end(); ++iStr){ *pChar = *iStr; ++pChar; }
130 for(iStr=comment.begin(); iStr!=comment.end(); ++iStr){ *(++pChar) = *iStr; }
135 return (blobSizeInBytes/
sizeof(uint32_t));
147 return 0x80000000 | (gain << 24) | nChans;
151 if (gainAndnChans & 0x80000000) {
153 return (gainAndnChans>>24) & 0x7F;
157 return (gainAndnChans>>16) & 0xFFFF;
161 if (gainAndnChans & 0x80000000) {
163 return gainAndnChans & 0xFFFFFF;
167 return gainAndnChans & 0xFFFF;
182 sizeof(uint64_t)/
sizeof(uint32_t));
183 return std::string(iBeg);
196 sizeof(uint64_t)/
sizeof(uint32_t));
198 iBeg = std::find(iBeg,iEnd,0);
199 return std::string(++iBeg);
210 char* iBeg = ::ctime_r(&timeStamp, buf);
212 while(*iEnd!=
'\n'){++iEnd;}
213 return std::string(iBeg,iEnd-iBeg);
232 stm <<
"ObjType : " <<
getObjType() << std::endl;
235 stm <<
"NObjs : " <<
getNObjs() << std::endl;
236 stm <<
"NChannels : " <<
getNChans() << std::endl;
237 stm <<
"NGains : " <<
getNGains() << std::endl;
239 stm <<
"=== No comment available ===" << std::endl;
242 stm <<
"Author : " <<
getAuthor() << std::endl;
244 stm <<
"Comment: : " <<
getComment() << std::endl;
This class provides the core BLOB infrastructure.
uint16_t getObjType() const
Returns the BLOB object type.
std::string getDate() const
Returns the date of the comment as string (derived from timestamp)
CaloCondBlobBase & operator=(const CaloCondBlobBase &other)
Assignment operator.
virtual ~CaloCondBlobBase()
Dtor.
uint32_t getNGains() const
Returns the number of gains stored for each channel.
uint64_t getTimeStamp() const
Returns the unix timestamp of the comment (seconds since 1.1.1970)
uint32_t getObjSizeUint32() const
Returns the size of a data object in units of uint32_t.
const uint32_t * getBlobStart() const
Returns the BLOB start address as uint32_t pointer.
static uint32_t packGainAndNchans(const uint32_t gain, const uint32_t nChans)
bool m_isBlobOwner
Do I own the BLOB?
std::string getAuthor() const
Returns the comment author.
static uint32_t unpacknGains(const uint32_t gainAndnChans)
uint32_t getCommentSizeUint32() const
Returns the space occupied by the comment fields in units of uint32_t.
unsigned m_sizeOfObj
Chache of some frequently-used numbers.
static uint32_t unpacknChans(const uint32_t gainAndnChans)
void dumpHeader(std::ostream &stm) const
Prints the BLOB header summary information.
uint32_t createBlob(uint16_t objType, uint16_t objVersion, uint32_t objSizeUint32, uint32_t nObjs, uint32_t nChans, uint16_t nGains, const std::string &author="", const std::string &comment="", uint64_t timeStamp=0)
(re-)creation of the referenced BLOB object.
CaloCondBlobBase(const CaloCondBlobBase &other)
Copy Ctor.
uint32_t getNObjs() const
Returns the number of data objects stored int the BLOB.
std::string getComment() const
Returns the actual comment.
uint32_t getNChans() const
Returns the number of channels stored in the BLOB.
uint32_t getObjSizeByte() const
Returns the size of a data object in units of bytes.
uint16_t getObjVersion() const
Returns the BLOB object version.
uint32_t getCommentSizeChar() const
Returns the space occupied by the comment fields in units of chars.
coral::Blob * m_blob_nc
Non-const reference to the BLOB.
std::string getFullComment() const
Returns a formated string build from all comment fields.
unsigned int getHdrSize() const
Returns the size of the header in units of uint32_t.
const coral::Blob * m_blob
Const reference to the BLOB (always there)
const void * m_pDataStart
static std::string getClassName(CaloCondType::TYPE type)
Returns the class name.
Thrown if coral::Blob does not conform with expected structure.
void set_unaligned< uint64_t >(uint8_t *ATH_RESTRICT &p, uint64_t val)
Write little-endian values through possibly unaligned pointers.