1 | // Guy Le Meur 03/2000
|
---|
2 |
|
---|
3 |
|
---|
4 | #ifndef FITSNTuple_SEEN
|
---|
5 | #define FITSNTuple_SEEN
|
---|
6 | #include "machdefs.h"
|
---|
7 | #include "ntuple.h"
|
---|
8 | #include "anydataobj.h"
|
---|
9 | #include "ppersist.h"
|
---|
10 | #include "fitsfile.h"
|
---|
11 |
|
---|
12 | namespace SOPHYA {
|
---|
13 | ///////////////////////////////////////////////////////////////////
|
---|
14 | // Classe pour la gestion de persistance sur fichiers fits
|
---|
15 | // pout NTuple
|
---|
16 | ////////////////////////////////////////////////////////////////
|
---|
17 | class FITS_NTuple : public FitsIOHandler
|
---|
18 | {
|
---|
19 |
|
---|
20 | public:
|
---|
21 |
|
---|
22 | FITS_NTuple();
|
---|
23 | FITS_NTuple(char inputfile[],int hdunum=0);
|
---|
24 | FITS_NTuple(const NTuple & obj);
|
---|
25 | FITS_NTuple(NTuple* obj);
|
---|
26 | virtual ~FITS_NTuple();
|
---|
27 |
|
---|
28 | virtual AnyDataObj* DataObj() { return(dobj_); }
|
---|
29 | virtual void SetDataObj(AnyDataObj & o)
|
---|
30 | {
|
---|
31 | NTuple* po = dynamic_cast< NTuple* >(& o);
|
---|
32 | if (po == NULL) return;
|
---|
33 | if (ownobj_ && dobj_) delete dobj_;
|
---|
34 | dobj_ = po;
|
---|
35 | ownobj_ = false;
|
---|
36 | }
|
---|
37 | virtual int CheckHandling(AnyDataObj & o)
|
---|
38 | {
|
---|
39 | if (typeid(o) == typeid(NTuple)) return 2;
|
---|
40 | NTuple * po = dynamic_cast< NTuple * >(& o);
|
---|
41 | if (po == NULL) return 0;
|
---|
42 | else return 1;
|
---|
43 | }
|
---|
44 |
|
---|
45 | virtual int CheckReadability(FitsInOutFile& is);
|
---|
46 |
|
---|
47 | virtual FitsHandlerInterface* Clone()
|
---|
48 | { return new FITS_NTuple() ; }
|
---|
49 |
|
---|
50 | /*!
|
---|
51 | fill the XNTuple only with lines from firstLine-th to (firstLine+numberOfLines-1)-th of the FITS-file inputfile.
|
---|
52 | \param <firstLine> first line to be read (the first line of the file is numbered 0)
|
---|
53 | \param <numberOfLines> number of lines to be read
|
---|
54 | */
|
---|
55 | void ReadLines(char inputfile[],int firstLine, int numberOfLines,int hdunum=0);
|
---|
56 |
|
---|
57 | inline operator NTuple() { return(*dobj_); }
|
---|
58 | inline NTuple * getObj() { return(dobj_); }
|
---|
59 |
|
---|
60 | protected:
|
---|
61 |
|
---|
62 | // implementation de FitsFile
|
---|
63 | virtual void ReadFromFits(FitsInFile& is);
|
---|
64 | virtual void WriteToFits(FitsOutFile& os) ;
|
---|
65 |
|
---|
66 | private :
|
---|
67 |
|
---|
68 | inline void InitNull() { fistLineToBeRead_= -1; numberOfLinesToBeRead_= -1;}
|
---|
69 |
|
---|
70 |
|
---|
71 | // attributs de classe
|
---|
72 | NTuple* dobj_;
|
---|
73 | bool ownobj_;
|
---|
74 | int fistLineToBeRead_;
|
---|
75 | int numberOfLinesToBeRead_;
|
---|
76 | };
|
---|
77 | //////////////////////////////////////////////////////////////////
|
---|
78 |
|
---|
79 | inline FitsInOutFile& operator << (FitsInOutFile& fios, NTuple & nt)
|
---|
80 | { FITS_NTuple fih(&nt); fih.Write(fios); return (fios); }
|
---|
81 |
|
---|
82 | inline FitsInOutFile& operator >> (FitsInOutFile& fiis, NTuple & nt)
|
---|
83 | { FITS_NTuple fih(&nt); fiis.SkipEmptyFirstHDU();
|
---|
84 | fih.Read(fiis); fiis.MoveToNextHDU(); return (fiis); }
|
---|
85 |
|
---|
86 |
|
---|
87 | } // Fin du namespace
|
---|
88 |
|
---|
89 | #endif
|
---|