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

Last change on this file since 10758 was 10741, checked in by lyard, 14 years ago
added configurable grouping and did some cosmetics to the code (removed tabs)
File size: 3.2 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 void 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;
61 public:
62
63 Fits() : fFile(NULL),
64 fOwner(false),
65 fTable(NULL),
66 fNumRows(0),
67 fDataPointer(NULL),
68 fDataNumBytes(0),
69 fCopyBuffer(NULL),
70 fTotalNumBytes(0),
71 fEndMjD(0.0),
72 fRefMjD(0.0),
73 fFileName(""),
74 fNumOpenFitsFiles(NULL),
75 fMess(NULL)
76 {}
77
78 virtual ~Fits()
79 {
80 if (IsOpen())
81 Close();
82 }
83 ///returns wether or not the file is currently open or not
84 bool IsOpen() {return fFile != NULL;}
85
86 ///Adds a column that exists in all FITS files
87 void AddStandardColumn(Description& desc, string dataFormat, void* dataPointer, long unsigned int numDataBytes);
88
89 ///Adds columns specific to the service being logged.
90 void InitDataColumns(vector<Description> desc, vector<string>& dataFormat, void* dataPointer, int numDataBytes);
91
92 ///Opens a FITS file
93 void Open(const string& fileName, const string& tableName, CCfits::FITS* file, int* fitsCounter, MessageImp* out);//ostream& out);
94
95 ///Write one line of data. Use the given converter.
96 void Write(Converter* conv);
97
98 ///Close the currently opened file.
99 void Close();
100
101 ///Get the size currently written on the disk
102 int GetWrittenSize();
103private:
104 template <typename T>
105 void WriteSingleHeaderKey(string name, T value, string comment);
106
107};//Fits
108
109
110#endif /*FITS_H_*/
111
Note: See TracBrowser for help on using the repository browser.