source: trunk/Mars/mfileio/MFitsArray.h@ 18679

Last change on this file since 18679 was 18140, checked in by tbretz, 10 years ago
Having the destructor abstract didn't link anymore... I don't know why. Maybe it is not properly overwritten everywhere.
File size: 3.2 KB
Line 
1#ifndef MARS_MFitsArray
2#define MARS_MFitsArray
3
4//#include "astroroot.h"
5//#include "fitsio.h"
6#ifndef MARS_fits
7#include "fits.h"
8#endif
9
10#ifndef MARS_ofits
11#include "ofits.h"
12#endif
13
14class TClonesArray;
15class MLog;
16
17///////////////////////////////////////////////////////////////////////////////
18// A base class for arrays, which has to be written into their own FITS table
19class MArrayHelperBase
20{
21protected:
22
23 // the FITS table to which the data are written
24 ofits* fFitsTable;
25
26 // number of elements in fClonesArray / MArrayX / TArrayX during
27 // one write operation. This number is written into a column of
28 // the parent FITS table.
29 UInt_t fArraySize;
30
31public:
32 virtual ~MArrayHelperBase() { };
33
34 ofits* GetFitsTable() {return fFitsTable;}
35 UInt_t * GetArraySizePtr() {return &fArraySize;}
36
37 Bool_t OpenFitsTable(const char * baseFileName, const char * dataName,
38 const char * option, MLog * log);
39
40 virtual void InitCol() {}
41
42 virtual Int_t Read() = 0;
43 virtual void Write() = 0;
44
45};
46
47///////////////////////////////////////////////////////////////////////////////
48// A class to write data of one TClonesArray into one FITS table.
49class MClonesArrayHelper : public MArrayHelperBase
50{
51 // data of this TClonesArray are written to fFitsTable
52 TClonesArray * fClonesArray;
53
54
55
56 // fFitsTable writes during one fFitsTable.Write() call data which
57 // are currently stored in this buffer. That means the data pointers
58 // of fFitsTable for each column point to this data buffer.
59 Byte_t * fDataBuffer;
60
61 // the size of fDataBufferer.
62 Int_t fDataBufferSize;
63
64 // the first used byte in fDataBuffer
65 Int_t fStartOfData;
66
67public:
68 MClonesArrayHelper(TClonesArray * clonesArray, MLog * log, Bool_t & status);
69 MClonesArrayHelper(const MClonesArrayHelper & clHelper);
70
71 ~MClonesArrayHelper() {delete [] fDataBuffer;}
72
73 void * GetDataBuffer() {return fDataBuffer;}
74
75 Int_t Read();
76 void Write();
77
78};
79
80///////////////////////////////////////////////////////////////////////////////
81// Classes to write and read data of MArray* classes
82template<class BaseT, class ClassT>
83 class MArrayHelper : public MArrayHelperBase
84{
85 ClassT * fArrayClass;
86
87 BaseT fDataBuffer;
88 char fDataType[10];
89
90public:
91 MArrayHelper(ClassT * arrayClass, const char * dataType)
92 {fArrayClass = arrayClass;
93 strcpy(fDataType, dataType);}
94
95 void InitCol()
96 {
97 //FIXME ETIENNE HERE
98// fFitsTable.InitCol("Data", fDataType, &fDataBuffer);
99// fFitsTable->AddColumn(
100// fFitsTables[tableName]->AddColumn(count, typeChar, truncatedName, unit, truncatedComment);
101
102 }
103
104 Int_t Read() { return 0;}
105 void Write()
106 {
107 fArraySize = fArrayClass->GetSize();
108 for (UInt_t idx = 0; idx < fArraySize; idx++)
109 {
110 fDataBuffer = (*fArrayClass)[idx];
111//FIXME ETIENNE HERE
112 // fFitsTable.Write();
113 }
114 }
115
116
117};
118
119#endif
120
Note: See TracBrowser for help on using the repository browser.