/* * pxirootRecord.hh * * Created on: Mar 24, 2014 * Author: yqiang */ #ifndef PXIROOTRECORD_HH_ #define PXIROOTRECORD_HH_ #include #include #include class pxirootRecord: public TObject { private: struct timespec prrTime; // POSIX timestamp TArrayF prrData; // ROOT array of floats public: pxirootRecord(struct timespec posixTime, unsigned nElm, const float* arrayPtr) : TObject(), prrTime(posixTime), prrData(nElm, arrayPtr) { ; } pxirootRecord& operator=(const pxirootRecord &record) { *dynamic_cast(this) = record; prrTime = record.prrTime; prrData = record.prrData; return *this; } virtual ~pxirootRecord() { } ; void CopyToBuffer(void* bufferPtr); inline struct timespec GetTimeStamp() const { return prrTime; } inline TArrayF& GetData() { return prrData; } inline struct timespec SetTimeStamp(struct timespec posixTime) { return prrTime = posixTime; } inline TArrayF& SetData(Int_t nElm, const Float_t* arrayPtr) { return prrData = TArrayF(nElm, arrayPtr); } inline TArrayF& SetData(const TArrayF& array) { return prrData = array; } }; void pxirootRecord::CopyToBuffer(void* bufferPtr) { // Copy second memcpy(bufferPtr, &(prrTime.tv_sec), sizeof(Long64_t)); // Copy Nanosecond void * currentPtr = &((static_cast(bufferPtr))[1]); memcpy(currentPtr, &(prrTime.tv_nsec), sizeof(Long64_t)); // Copy Data array currentPtr = &((static_cast(bufferPtr))[2]); memcpy(currentPtr, prrData.fArray, prrData.GetSize() * sizeof(Float_t)); return; } #endif /* PXIROOTRECORD_HH_ */