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

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