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

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