source: trunk/FACT++/src/FactFits.h@ 10365

Last change on this file since 10365 was 10365, checked in by lyard, 11 years ago
Moved from FactFits to Fits
File size: 2.5 KB
Line 
1#ifndef FITS_H_
2#define FITS_H_
3
4#include <CCfits/CCfits>
5#include <vector>
6#include <iostream>
7
8#include "Description.h"
9
10using namespace CCfits;
11
12class Fits
13{
14 private:
15 ///The CCfits object to the FITS file
16 FITS* fFile;
17 ///The CCfits Table
18 Table* fTable;
19 ///The current number of Rows in the table
20 int fNumRows;
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 std::vector<Description> fStandardColDesc;
25 ///Format of the standard columns.
26 std::vector<std::string> fStandardFormats;
27 ///the pointers to the standard variables
28 std::vector<void*> fStandardPointers;
29 ///the number of bytes taken by each standard variable
30 std::vector<int> fStandardNumBytes;
31 ///the vector of data column names
32 std::vector<Description> fDataColDesc;
33 ///the data format of the data columns
34 std::vector<std::string> fDataFormats;
35 ///the pointer to the contiguous memory location where the data is stored (i.e. the dim data pointer)
36 void* fDataPointer;
37 ///the size of the data, in bytes.
38 int fDataNumBytes;
39 ///the copy buffer. Required to put the standard and data variable in contguous memory
40 unsigned char* fCopyBuffer;
41 ///the total number of bytes per FITS row
42 int fTotalNumBytes;
43 ///to keep track of the time of the latest written entry (to update the header when closing the file)
44 double fEndMjD;
45 ///Write the FITS header keys
46 void WriteHeaderKeys();
47
48 public:
49
50 Fits() : fFile(NULL),
51 fTable(NULL),
52 fNumRows(0),
53 fDataPointer(NULL),
54 fDataNumBytes(0),
55 fCopyBuffer(NULL),
56 fTotalNumBytes(0),
57 fEndMjD(0.0)
58 {}
59
60 virtual ~Fits()
61 {
62 if (IsOpen())
63 Close();
64 }
65 ///returns wether or not the file is currently open or not
66 bool IsOpen() {return fFile != NULL;}
67
68 ///Adds a column that exists in all FITS files
69 void AddStandardColumn(Description& desc, std::string dataFormat, void* dataPointer, long unsigned int numDataBytes);
70
71 ///Adds columns specific to the service being logged.
72 void InitDataColumns(std::vector<Description> desc, std::vector<std::string>& dataFormat, void* dataPointer, int numDataBytes);
73
74 ///Opens a FITS file
75 void Open(const std::string& fileName, const std::string& tableName);
76
77 ///Write one line of data. Use the given converter.
78 void Write(Converter* conv);
79
80 ///Close the currently opened file.
81 void Close();
82
83};//Fits
84
85#endif /*FITS_H_*/
86
Note: See TracBrowser for help on using the repository browser.