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

Last change on this file since 11834 was 11716, checked in by tbretz, 13 years ago
Make use of the new FitsFile class.
File size: 2.8 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
21 ///Name of the "standard", i.e. data found in every fits file
22 ///TODO make these variable static so that they are shared by every object.
23 ///TODO add also a static boolean to initialize these only once
24 vector<Description> fStandardColDesc;
25 ///Format of the standard columns.
26 vector<string> fStandardFormats;
27 ///the pointers to the standard variables
28 vector<void*> fStandardPointers;
29 ///the number of bytes taken by each standard variable
30 vector<int> fStandardNumBytes;
31
32 ///the vector of data column names
33 vector<Description> fDataColDesc;
34 ///the data format of the data columns
35 vector<string> fDataFormats;
36
37 ///the pointer to the contiguous memory location where the data is stored (i.e. the dim data pointer)
38 void* fDataPointer;
39 ///the copy buffer. Required to put the standard and data variable in contguous memory
40 vector<char> fCopyBuffer;
41 ///to keep track of the time of the latest written entry (to update the header when closing the file)
42 double fEndMjD;
43 ///Keep track of number of opened fits
44 uint32_t* fNumOpenFitsFiles;
45 ///were to log the errors
46 MessageImp* fMess;
47
48 ///Write the FITS header keys
49 bool WriteHeaderKeys();
50
51public:
52 ///current run number being logged
53 uint32_t fRunNumber;
54
55 Fits() : fFile(NULL),
56 fDataPointer(NULL),
57 fEndMjD(0.0),
58 fNumOpenFitsFiles(NULL),
59 fMess(NULL),
60 fRunNumber(0)
61 {}
62
63 virtual ~Fits()
64 {
65 Close();
66 }
67
68 ///returns wether or not the file is currently open or not
69 bool IsOpen() const { return fFile != NULL && fFile->IsOpen(); }
70
71 ///Adds a column that exists in all FITS files
72 void AddStandardColumn(const Description& desc, const string &dataFormat, void* dataPointer, long unsigned int numDataBytes);
73
74 ///Adds columns specific to the service being logged.
75 void InitDataColumns(const vector<Description> &desc, const vector<string>& dataFormat, void* dataPointer);
76
77 ///Opens a FITS file
78 bool Open(const string& fileName, const string& tableName, uint32_t* fitsCounter, MessageImp* out, int runNumber, CCfits::FITS *file=0);//ostream& out);
79
80 ///Write one line of data. Use the given converter.
81 bool Write(const Converter &conv);
82
83 ///Close the currently opened file.
84 void Close();
85
86 ///Get the size currently written on the disk
87 int GetWrittenSize() const;
88
89 string GetName() const { return fFile ? fFile->GetName() : ""; }
90
91};//Fits
92
93
94#endif /*FITS_H_*/
95
96// WriteToFITS vs Open/Close
Note: See TracBrowser for help on using the repository browser.