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