| 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 | */ | 
|---|
| 6 |  | 
|---|
| 7 |  | 
|---|
| 8 | #ifndef FITSNTuple_SEEN | 
|---|
| 9 | #define FITSNTuple_SEEN | 
|---|
| 10 | #include "machdefs.h" | 
|---|
| 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 | //////////////////////////////////////////////////////////////// | 
|---|
| 21 | class  FITS_NTuple : public FitsIOHandler | 
|---|
| 22 | { | 
|---|
| 23 |  | 
|---|
| 24 | public: | 
|---|
| 25 |  | 
|---|
| 26 | FITS_NTuple(); | 
|---|
| 27 | FITS_NTuple(char inputfile[],int hdunum=0); | 
|---|
| 28 | FITS_NTuple(const NTuple & obj); | 
|---|
| 29 | FITS_NTuple(NTuple* obj); | 
|---|
| 30 | virtual ~FITS_NTuple(); | 
|---|
| 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 | } | 
|---|
| 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 | } | 
|---|
| 48 |  | 
|---|
| 49 | virtual int         CheckReadability(FitsInOutFile& is); | 
|---|
| 50 |  | 
|---|
| 51 | virtual FitsHandlerInterface* Clone() | 
|---|
| 52 | { return new FITS_NTuple() ; } | 
|---|
| 53 |  | 
|---|
| 54 | /*! | 
|---|
| 55 | fill the NTuple only with lines from firstLine-th to (firstLine+numberOfLines-1)-th of the FITS-file inputfile. | 
|---|
| 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 | */ | 
|---|
| 59 | void ReadLines(char inputfile[],int firstLine, int numberOfLines,int hdunum=0); | 
|---|
| 60 |  | 
|---|
| 61 | inline operator NTuple() { return(*dobj_); } | 
|---|
| 62 | inline NTuple * getObj() { return(dobj_); } | 
|---|
| 63 |  | 
|---|
| 64 | protected: | 
|---|
| 65 |  | 
|---|
| 66 | // implementation de FitsFile | 
|---|
| 67 | virtual void ReadFromFits(FitsInFile& is); | 
|---|
| 68 | virtual void WriteToFits(FitsOutFile& os) ; | 
|---|
| 69 |  | 
|---|
| 70 | private : | 
|---|
| 71 |  | 
|---|
| 72 | inline void InitNull() { fistLineToBeRead_= -1; numberOfLinesToBeRead_= -1;} | 
|---|
| 73 |  | 
|---|
| 74 |  | 
|---|
| 75 | // attributs de classe | 
|---|
| 76 | NTuple* dobj_; | 
|---|
| 77 | bool ownobj_; | 
|---|
| 78 | int fistLineToBeRead_; | 
|---|
| 79 | int numberOfLinesToBeRead_; | 
|---|
| 80 | }; | 
|---|
| 81 | ////////////////////////////////////////////////////////////////// | 
|---|
| 82 |  | 
|---|
| 83 | inline FitsInOutFile& operator << (FitsInOutFile& fios, NTuple & nt) | 
|---|
| 84 | { FITS_NTuple fih(&nt); fih.Write(fios); return (fios); } | 
|---|
| 85 |  | 
|---|
| 86 | inline FitsInOutFile& operator >> (FitsInOutFile& fiis, NTuple & nt) | 
|---|
| 87 | { FITS_NTuple fih(&nt); fiis.SkipEmptyFirstHDU(); | 
|---|
| 88 | fih.Read(fiis); fiis.MoveToNextHDU(); return (fiis); } | 
|---|
| 89 |  | 
|---|
| 90 |  | 
|---|
| 91 | } // Fin du namespace | 
|---|
| 92 |  | 
|---|
| 93 | #endif | 
|---|