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