source: trunk/FACT++/src/Fits.h@ 14233

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