source: branches/FACT++_lidctrl_usb/src/Fits.h@ 18717

Last change on this file since 18717 was 14238, checked in by tbretz, 12 years ago
Removed the obsolete data pointer argument from InitDataColumns
File size: 2.7 KB
Line 
1#ifndef FACT_Fits
2#define FACT_Fits
3
4#include "Description.h"
5#include "FitsFile.h"
6
7class Converter;
8
9using namespace std;
10
11class Fits
12{
13private:
14 FitsFile *fFile;
15 string fFileName;
16
17 ///Name of the "standard", i.e. data found in every fits file
18 ///TODO make these variable static so that they are shared by every object.
19 ///TODO add also a static boolean to initialize these only once
20 vector<Description> fStandardColDesc;
21 ///Format of the standard columns.
22 vector<string> fStandardFormats;
23 ///the pointers to the standard variables
24 vector<void*> fStandardPointers;
25 ///the number of bytes taken by each standard variable
26 vector<int> fStandardNumBytes;
27
28 ///the vector of data column names
29 vector<Description> fDataColDesc;
30 //Description of the table
31 string fTableDesc;
32 ///the data format of the data columns
33 vector<string> fDataFormats;
34
35 ///the copy buffer. Required to put the standard and data variable in contguous memory
36 vector<char> fCopyBuffer;
37 ///to keep track of the time of the latest written entry (to update the header when closing the file)
38 double fEndMjD;
39 ///Keep track of number of opened fits
40 uint32_t* fNumOpenFitsFiles;
41 ///were to log the errors
42 MessageImp* fMess;
43
44 ///Write the FITS header keys
45 bool WriteHeaderKeys();
46 //if a write error occurs
47 void MoveFileToCorruptedFile();
48
49
50
51public:
52 ///current run number being logged
53 int32_t fRunNumber;
54
55 Fits() : fFile(NULL),
56 fEndMjD(0.0),
57 fNumOpenFitsFiles(NULL),
58 fMess(NULL),
59 fRunNumber(0)
60 {}
61
62 virtual ~Fits()
63 {
64 Close();
65 }
66
67 ///returns wether or not the file is currently open or not
68 bool IsOpen() const { return fFile != NULL && fFile->IsOpen(); }
69
70 ///Adds a column that exists in all FITS files
71 void AddStandardColumn(const Description& desc, const string &dataFormat, void* dataPointer, long unsigned int numDataBytes);
72
73 ///Adds columns specific to the service being logged.
74 void InitDataColumns(const vector<Description> &desc, const vector<string>& dataFormat, MessageImp* out);
75
76 ///Opens a FITS file
77 bool Open(const string& fileName, const string& tableName, uint32_t* fitsCounter, MessageImp* out, int runNumber, CCfits::FITS *file=0);//ostream& out);
78
79 ///Write one line of data. Use the given converter.
80 bool Write(const Converter &conv, const void* data);
81
82 ///Close the currently opened file.
83 void Close();
84
85 ///Flush the currently opened file to disk.
86 void Flush();
87
88 ///Get the size currently written on the disk
89 int GetWrittenSize() const;
90
91 string GetName() const { return fFile ? fFile->GetName() : ""; }
92
93};//Fits
94
95
96#endif /*FITS_H_*/
97
98// WriteToFITS vs Open/Close
Note: See TracBrowser for help on using the repository browser.