source: Sophya/trunk/SophyaExt/FitsIOServer/fabtwriter.h@ 2450

Last change on this file since 2450 was 2450, checked in by cmv, 22 years ago

possibilite d extension fits ds le writer cmv 29/10/2003

File size: 3.9 KB
Line 
1/* Interface Fits BINARY/ASCII Table Writer cmv 26/09/2001 */
2#ifndef FABTWRITER_H_SEEN
3#define FABTWRITER_H_SEEN
4
5#include "machdefs.h"
6#include <iostream>
7#include <string.h>
8#include <string>
9
10#include "anydataobj.h"
11#include "tvector.h"
12#include "FitsIO/fitsio.h"
13
14#include <vector>
15
16namespace SOPHYA {
17
18//! Class for writing a FITS ASCII or BINARY table
19class FitsABTWriter : public AnyDataObj {
20public:
21 FitsABTWriter(string fname,int hdutype=BINARY_TBL,int lp=0);
22 FitsABTWriter(const char* cfname,int hdutype=BINARY_TBL,int lp=0);
23 FitsABTWriter(string fname,bool update,int hdutype=BINARY_TBL,int lp=0);
24 FitsABTWriter(const char* cfname,bool update,int hdutype=BINARY_TBL,int lp=0);
25 virtual ~FitsABTWriter();
26
27 void Flush(void);
28
29 //! Write a double value in Fits header.
30 void WriteKey(const char *keyname,double val,char* comment=NULL);
31 //! Write a long value in Fits header.
32 void WriteKey(const char *keyname,long val,char* comment=NULL);
33 //! Write a string value in Fits header.
34 void WriteKey(const char *keyname,string val,char* comment=NULL);
35 //! Write a character string value in Fits header.
36 inline void WriteKey(const char *keyname,char* val,char* comment=NULL)
37 {string dum=val; WriteKey(keyname,dum,comment);}
38
39 //! Add a new column to the FITS table and return its number (see addcol).
40 inline int AddCol(string label,string tform=string("")
41 ,string tunit=string(""),int datatype=TDOUBLE)
42 {return addcol(label.c_str(),tform.c_str(),tunit.c_str(),datatype);}
43 //! Add a new column to the FITS table and return its number (see addcol).
44 inline int AddCol(const char* label,const char* tform=""
45 ,const char* tunit="",int datatype=TDOUBLE)
46 {return addcol(label,tform,tunit,datatype);}
47
48 //! Set the FITS table extension name
49 inline void SetExtName(string extname=string("")) {ExtName = extname;}
50 //! Set the FITS table extension name
51 inline void SetExtName(char* extname="") {ExtName = extname;}
52 //! Set debug level
53 inline void SetDebug(int lp=0) {DbgLevel = (unsigned short) lp;}
54
55 void Write(int col,long row,uint_1 val);
56 void Write(int col,long row,int_2 val);
57 void Write(int col,long row,uint_2 val);
58 void Write(int col,long row,int_4 val);
59 void Write(int col,long row,uint_4 val);
60 void Write(int col,long row,int_8 val);
61 void Write(int col,long row,float val);
62 void Write(int col,long row,double val);
63 long Write(int col,long row,TVector<uint_2>& val);
64 long Write(int col,long row,TVector<int_4>& val);
65 long Write(int col,long row,TVector<int_8>& val);
66 long Write(int col,long row,TVector<float>& val);
67 long Write(int col,long row,TVector<double>& val);
68 //! Return the number of overflows managed by cfitsio
69 inline unsigned long GetNOverFlow(void) {return NOverFlow;}
70
71 //! Return the number of created columns
72 inline int GetNbCol(void) {return (int) Label.size();}
73
74 //! Print to os
75 virtual void Print(ostream& os,int lp=1) const;
76 //! Print to stdout
77 inline void Print(int lp=1) const {Print(cout,lp);}
78
79protected:
80 struct KeyDouble {string keyname; double val; string comment;};
81 struct KeyLong {string keyname; long val; string comment;};
82 struct KeyString {string keyname; string val; string comment;};
83
84 void cr_or_upd_fits(const char *cfname,bool update,int hdutype,int lp);
85 int addcol(const char* label,const char* tform
86 ,const char* tunit,int datatype);
87 void createtbl(void);
88 void writekeys(void);
89 void printerrorwrite(const char* type,int col,long row,int sta);
90 void printerror(int sta) const;
91
92 string FitsFN,ExtName;
93 bool Update;
94 int HduType;
95 unsigned short DbgLevel;
96 fitsfile *FitsPtr;
97 bool FirstTime;
98 vector<string> Label;
99 vector<string> TForm;
100 vector<string> TUnit;
101 unsigned long NOverFlow;
102
103 vector<struct KeyDouble> DoubleKey;
104 vector<struct KeyLong> LongKey;
105 vector<struct KeyString> StringKey;
106};
107
108} // namespace SOPHYA
109#endif /* FABTWRITER_H_SEEN */
Note: See TracBrowser for help on using the repository browser.