Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
THaCodaData.h
Go to the documentation of this file.
1#ifndef Podd_THaCodaData_h_
2#define Podd_THaCodaData_h_
3
5//
6// THaCodaData
7// Abstract class of CODA data.
8//
9// THaCodaData is an abstract class of CODA data. Derived
10// classes will be typically either a CODA file (a disk
11// file) or a connection to the ET system. Public methods
12// allow to open (i.e. set up), read, write, etc.
13//
14// author Robert Michaels (rom@jlab.org)
15//
17
18
19#include "Rtypes.h"
20#include "TString.h"
21#include "Decoder.h"
22#include "CustomAlloc.h"
23#include <cstdio> // for EOF
24#include <vector>
25#include <cassert>
26
27// Return codes from codaNNN routines
28#define CODA_OK 0 // OK
29#define CODA_EOF EOF // End of file
30#define CODA_ERROR -128 // Generic error return code
31#define CODA_FATAL -255 // Fatal error
32
33namespace Decoder {
34
35// Dynamically-sized event buffer
36class EvtBuffer {
37public:
38 explicit EvtBuffer( UInt_t initial_size = 0 );
39
40 void recordSize();
41 void updateSize() {
42 if( (fNevents % fUpdateInterval) == 0 &&
43 fChanged && !fDidGrow && fSaved.size() == fMaxSaved )
44 updateImpl();
45 }
46 Bool_t grow( UInt_t newsize = 0 );
47 UInt_t operator[]( UInt_t i ) { assert(i < size()); return fBuffer[i]; }
48 UInt_t* get() { return fBuffer.data(); }
49 UInt_t size() const { return fBuffer.size(); }
50 void reset();
51
52private:
53 VectorUIntNI fBuffer; // Raw data buffer
60
61 void updateImpl();
62};
63
65
66public:
67
69 THaCodaData(const THaCodaData &fn) = delete;
70 THaCodaData& operator=(const THaCodaData &fn) = delete;
71 virtual ~THaCodaData() = default;
72 virtual Int_t codaOpen(const char* file_name, Int_t mode=1) = 0;
73 virtual Int_t codaOpen(const char* file_name, const char* session, Int_t mode=1) = 0;
74 virtual Int_t codaClose()=0;
75 virtual Int_t codaRead()=0;
76 UInt_t* getEvBuffer() { return evbuffer.get(); }
77 UInt_t getBuffSize() const { return evbuffer.size(); }
78 virtual Bool_t isOpen() const = 0;
79 virtual Int_t getCodaVersion();
80 void setVerbosity(int level) { verbose = level; }
81 Bool_t isGood() const { return fIsGood; }
82
83protected:
84 static Int_t ReturnCode( Int_t evio_retcode );
85 void staterr(const char* tried_to, Int_t status) const;
86
87 EvtBuffer evbuffer; // Dynamically-sized event buffer
89 Int_t handle; // EVIO data handle
90 Int_t verbose; // Message verbosity (0=quiet, 1=verbose, 2=debug)
92
93 ClassDef(THaCodaData,0) // Base class of CODA data (file, ET conn, etc)
94
95};
96
97}
98
99#endif
int Int_t
unsigned int UInt_t
bool Bool_t
#define ClassDef(name, id)
VectorUIntNI fBuffer
Definition THaCodaData.h:53
VectorUInt fSaved
Definition THaCodaData.h:54
UInt_t size() const
Definition THaCodaData.h:49
UInt_t operator[](UInt_t i)
Definition THaCodaData.h:47
Bool_t grow(UInt_t newsize=0)
THaCodaData(const THaCodaData &fn)=delete
virtual ~THaCodaData()=default
virtual Bool_t isOpen() const =0
UInt_t * getEvBuffer()
Definition THaCodaData.h:76
void staterr(const char *tried_to, Int_t status) const
virtual Int_t codaRead()=0
virtual Int_t codaOpen(const char *file_name, const char *session, Int_t mode=1)=0
virtual Int_t codaClose()=0
UInt_t getBuffSize() const
Definition THaCodaData.h:77
static Int_t ReturnCode(Int_t evio_retcode)
Bool_t isGood() const
Definition THaCodaData.h:81
void setVerbosity(int level)
Definition THaCodaData.h:80
THaCodaData & operator=(const THaCodaData &fn)=delete
virtual Int_t codaOpen(const char *file_name, Int_t mode=1)=0
virtual Int_t getCodaVersion()
std::vector< UInt_t > VectorUInt
Definition CustomAlloc.h:36
std::vector< UInt_t, default_init_allocator< UInt_t > > VectorUIntNI
Definition CustomAlloc.h:38