/* * pxirootManager.hh * * Created on: Mar 24, 2014 * Author: yqiang */ #ifndef PXIROOTMANAGER_HH_ #define PXIROOTMANAGER_HH_ #include #include #include #include #include #include #include #include #include #include "pxirootFile.hh" #include "pxirootRecord.hh" class recordBuffer { public: string treename; pxirootRecord record; inline recordBuffer(string treeName, pxirootRecord prRecord) : treename(treeName), record(prRecord) { } recordBuffer& operator=(const recordBuffer &rbuffer) { treename = rbuffer.treename; record = rbuffer.record; return *this; } virtual ~recordBuffer() { } }; class pxirootManager { private: string prmPrefix; string prmSuffix; public: static pxirootManager* selfPtr; // Self pointer static Int_t prmCompressFactor; // Compression factor static UInt_t prmFileSizeTolerance; // Maximum file size static std::queue prmBuffer; // record buffer pthread_t prmThread; bool prmStop; pxirootFile* prmFile; string prmDir; string prmFileName; long prmFileLimit; long prmFileSize; pthread_mutex_t *prmMutex; pxirootManager(); virtual ~pxirootManager(); inline static pxirootManager* GetInstance() { if (selfPtr == 0) selfPtr = new pxirootManager(); return selfPtr; } void StartDAQ(string dir, string prefix, string suffix, long nlim); void NewRootFile(); void WriteFile(const char* channelName, struct timespec* timeStamp, float* buffPtr, int nElm); void CloseFile(); inline pxirootFile* GetFile() const { return prmFile; } inline pxirootFile* SetFile(pxirootFile* file) { return prmFile = file; } }; void *WriteThread(void* argument); #endif /* PXIROOTMANAGER_HH_ */