Changeset 2897 in Sophya


Ignore:
Timestamp:
Jan 13, 2006, 11:05:52 AM (20 years ago)
Author:
ansari
Message:

Mise en place de l heritage FitsIOHandler (ancien) de FitsHandlerInterface pour une gestion commune - a partir de FitsManager - Reza 13/01/2006

Location:
trunk/SophyaExt/FitsIOServer
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaExt/FitsIOServer/fiosinit.cc

    r2895 r2897  
    77#include "fitshdtable.h"
    88#include "fitsarrhand.h"
     9
     10#include "fitsntuple.h"
     11#include "fitsspherehealpix.h"
     12#include "fitsspherethetaphi.h"
     13#include "fitslocalmap.h"
     14
    915
    1016#include <iostream>
     
    3339  FitsManager::RegisterHandler(new FitsHandler<BaseDataTable>, 1, "DataTable");
    3440
     41  // Enregistrement des classes heritant de FitsIOHandler
     42  FitsManager::RegisterHandler(new FITS_NTuple, 0, "NTuple");
     43 
     44  FitsManager::RegisterHandler(new FITS_SphereHEALPix<r_4> , 0, "SphereHEALPix<r_4>");
     45  FitsManager::RegisterHandler(new FITS_SphereHEALPix<r_8> , 0, "SphereHEALPix<r_8>");
     46  FitsManager::RegisterHandler(new FITS_SphereHEALPix<int_4> , 0, "SphereHEALPix<int_4>");
     47
     48  FitsManager::RegisterHandler(new FITS_SphereThetaPhi<r_4> , 0, "SphereThetaPhi<r_4>");
     49  FitsManager::RegisterHandler(new FITS_SphereThetaPhi<r_8> , 0, "SphereThetaPhi<r_8>");
     50  FitsManager::RegisterHandler(new FITS_SphereThetaPhi<int_4> , 0, "SphereThetaPhi<int_4>");
     51
     52  FitsManager::RegisterHandler(new FITS_LocalMap<r_4> , 0, "LocalMap<r_4>");
     53  FitsManager::RegisterHandler(new FITS_LocalMap<r_8> , 0, "LocalMap<r_8>");
     54  FitsManager::RegisterHandler(new FITS_LocalMap<int_4> , 0, "LocalMap<int_4>");
     55
    3556  cout << " ---- FitsIOServerInitiator / DEBUG ---- ListHandlers() : " << endl;
    3657  FitsManager::ListHandlers();
  • trunk/SophyaExt/FitsIOServer/fitsfile.cc

    r2860 r2897  
    244244}
    245245
     246void FitsIOHandler::Read(FitsInOutFile& is)
     247{
     248  FitsInFile fis(is);
     249  fis.ReadHeader(0);
     250  ReadFromFits(fis);
     251}
     252
    246253  /*! \fn void SOPHYA::FitsIOHandler::Read(FitsInFile& is, int hdunum)
    247254Read the data on extension hdunum (or primary header, if hdunum=1) from FitsInFIle. If hdunum is not addressed, , one reads the next extension, with respect to the current position.
     
    271278{
    272279  FitsOutFile of(flnm, FitsFile::unknown);
    273   Write(of);
    274 }
    275 
    276 void FitsIOHandler::Write(FitsOutFile& os)
    277 {
    278   WriteToFits(os);
     280  WriteToFits(of);
     281}
     282
     283void FitsIOHandler::Write(FitsInOutFile& os)
     284{
     285  FitsOutFile fos(os);
     286  WriteToFits(fos);
    279287}
    280288
  • trunk/SophyaExt/FitsIOServer/fitsfile.h

    r2860 r2897  
    55#include "dvlist.h"
    66#include "fitsinoutfile.h"
     7#include "fitshandler.h"
    78
    89#define OPENFILE    0
     
    5253//! Class for managing Interface for SOPHYA objects to FITS Format Files (uses cfitsio lib)
    5354
    54 class FitsIOHandler {
     55class FitsIOHandler : public FitsHandlerInterface {
    5556
    5657
     
    6061   void   Read(char flnm[],int hdunum= 0);
    6162   void   Write(char flnm[]) ;
    62    void   Read(FitsInFile& ifts, int hdunum=0);
    63    void   Write(FitsOutFile& ofts) ;
    64 
     63
     64   //Implementation par defaut de l'interface FitsHandlerInterface
     65   virtual AnyDataObj* DataObj() { return NULL; }
     66   virtual int         CheckHandling(AnyDataObj & o) { return 0; }
     67   virtual void        SetDataObj(AnyDataObj & o) { return; }
     68   virtual int         CheckReadability(FitsInOutFile& is) { return 0; }
     69   virtual FitsHandlerInterface* Clone() { return NULL; }
     70
     71   virtual void   Read(FitsInOutFile& ifts);
     72   virtual void   Write(FitsInOutFile& ofts) ;
     73
     74   virtual void   Read(FitsInFile& ifts, int hdunum=0);
    6575
    6676 protected:
  • trunk/SophyaExt/FitsIOServer/fitslocalmap.cc

    r2874 r2897  
    6868    ownobj_ = false;
    6969  }   
     70
     71template <class T>
     72int FITS_LocalMap<T>::CheckHandling(AnyDataObj & o)
     73{
     74  if ( typeid(o) == typeid( LocalMap< T > ) ) return 2;
     75  LocalMap<T> * po = dynamic_cast< LocalMap<T> * >(&o);
     76  if (po == NULL) return 0;
     77  else return 1;
     78}
     79
     80template <class T>
     81int FITS_LocalMap<T>::CheckReadability(FitsInOutFile& is)
     82{
     83  if (is.CurrentHDUType() !=  BINARY_TBL ) return 0;
     84  string key;
     85  key = "Content";
     86  string clsnm = is.KeyValue(key);
     87  if (clsnm != "LocalMap") return 0;
     88
     89  vector<string> colnames;
     90  vector<int> coltypes;
     91  vector<long> repcnt;
     92  vector<long> width;
     93  long ncols = is.GetColInfo(colnames, coltypes, repcnt, width);
     94  if (ncols < 1) return 0;
     95  T x;
     96  if (coltypes[0] == FitsTypes::DataType(x)) return 2 ;
     97  else return 1;
     98}
     99
     100template <class T>
     101FitsHandlerInterface* FITS_LocalMap<T>::Clone()
     102{
     103  return new FITS_LocalMap<T>() ;
     104}
    70105
    71106template <class T>
     
    195230  dvl["Content"]= "LocalMap";
    196231  dvl.SetComment("Content", "name of SOPHYA object");
     232  dvl["SOPCLSNM"]= "SOPHYA::LocalMap<T>";
     233  dvl.SetComment("SOPCLSNM", "SOPHYA class name");
    197234  // On ecrit les dataBlocks
    198235  vector<string> Noms;   
    199236  Noms.push_back(dvl.GetS("Content"));
    200   string extname("SIMULATION");
     237  //  string extname("SIMULATION");
     238  string extname = os.NextExtensionName();
    201239
    202240  // sortie sur image fits
  • trunk/SophyaExt/FitsIOServer/fitslocalmap.h

    r1322 r2897  
    3232inline operator LocalMap<T>() { return(*dobj_); }
    3333
     34virtual int         CheckHandling(AnyDataObj & o) ;
     35virtual int         CheckReadability(FitsInOutFile& is);
     36virtual FitsHandlerInterface* Clone();
     37
    3438protected :
    3539
  • trunk/SophyaExt/FitsIOServer/fitsntuple.cc

    r2615 r2897  
    5353  if (ownobj_ && dobj_ != NULL) delete dobj_;
    5454  //  if (column_ != NULL) delete [] column_;
     55}
     56
     57int  FITS_NTuple::CheckReadability(FitsInOutFile& is)
     58{
     59  if (is.CurrentHDUType() == IMAGE_HDU ) return 0;
     60  string key = "SOPCLSNM";
     61  string clsnm = is.KeyValue(key);
     62  if (clsnm == "SOPHYA::NTuple")  return 2;
     63  else return 1;
    5564}
    5665
     
    167176  dvl["Content"]= "NTuple";
    168177  dvl.SetComment("Content", "name of SOPHYA object");
     178  dvl["SOPCLSNM"]= "SOPHYA::NTuple";
     179  dvl.SetComment("SOPCLSNM", "SOPHYA class name");
    169180  // extension name
    170   string extname("NTuple_Binary_tbl");
     181  // string extname("NTuple_Binary_tbl");
     182  string extname = os.NextExtensionName();
    171183
    172184  vector<string> Noms(ncols);   
  • trunk/SophyaExt/FitsIOServer/fitsntuple.h

    r1231 r2897  
    3535    ownobj_ = false;
    3636  }   
     37virtual   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  }
    3744
     45virtual int         CheckReadability(FitsInOutFile& is);
     46
     47virtual FitsHandlerInterface* Clone()
     48    { return new FITS_NTuple() ; }
    3849
    3950/*!
  • trunk/SophyaExt/FitsIOServer/fitsspherehealpix.cc

    r2874 r2897  
    7171}
    7272
     73template <class T>
     74int FITS_SphereHEALPix<T>::CheckHandling(AnyDataObj & o)
     75{
     76  if ( typeid(o) == typeid( SphereHEALPix< T > ) ) return 2;
     77  SphereHEALPix<T> * po = dynamic_cast< SphereHEALPix<T> * >(&o);
     78  if (po == NULL) return 0;
     79  else return 1;
     80}
     81
     82template <class T>
     83int FITS_SphereHEALPix<T>::CheckReadability(FitsInOutFile& is)
     84{
     85  if (is.CurrentHDUType() !=  BINARY_TBL ) return 0;
     86  string key;
     87  key = "PIXTYPE";
     88  if ( is.KeyValue(key) != "HEALPIX")  return 0;
     89
     90  bool nosk = false;
     91  key = "ORDERING";
     92  is.KeyValue(key, nosk);
     93  bool nosk2 = false;
     94  key = "NSIDE";
     95  is.KeyValue(key, nosk2);
     96  if (nosk || nosk2) return 0;
     97
     98  vector<string> colnames;
     99  vector<int> coltypes;
     100  vector<long> repcnt;
     101  vector<long> width;
     102  long ncols = is.GetColInfo(colnames, coltypes, repcnt, width);
     103  if (ncols < 1) return 0;
     104  T x;
     105  if (coltypes[0] == FitsTypes::DataType(x)) return 2 ;
     106  else return 1;
     107}
     108
     109template <class T>
     110FitsHandlerInterface* FITS_SphereHEALPix<T>::Clone()
     111{
     112  return new FITS_SphereHEALPix<T>() ;
     113}
    73114
    74115
     
    104145  dvl["Content"]= "SphereHEALPix";
    105146  dvl.SetComment("Content", "name of SOPHYA object");
     147  dvl["SOPCLSNM"]= "SOPHYA::SphereHEALPix<T>";
     148  dvl.SetComment("SOPCLSNM", "SOPHYA class name");
    106149 
    107150  // On ecrit les dataBlocks
    108151  vector<string> Noms;   
    109152  Noms.push_back(dvl.GetS("Content"));
    110   string extname("SIMULATION");
     153  //  string extname("SIMULATION");
     154  string extname = os.NextExtensionName();
    111155
    112156  string Type;
  • trunk/SophyaExt/FitsIOServer/fitsspherehealpix.h

    r1752 r2897  
    2727virtual AnyDataObj* DataObj();
    2828virtual void        SetDataObj(AnyDataObj & o);
     29
     30virtual int         CheckHandling(AnyDataObj & o) ;
     31virtual int         CheckReadability(FitsInOutFile& is);
     32virtual FitsHandlerInterface* Clone();
    2933
    3034void Mollweide_picture_projection(char flnm[]);
  • trunk/SophyaExt/FitsIOServer/fitsspherethetaphi.cc

    r2874 r2897  
    6868  ownobj_ = false;
    6969}
     70
     71template <class T>
     72int FITS_SphereThetaPhi<T>::CheckHandling(AnyDataObj & o)
     73{
     74  if ( typeid(o) == typeid( SphereThetaPhi< T > ) ) return 2;
     75  SphereThetaPhi<T> * po = dynamic_cast< SphereThetaPhi<T> * >(&o);
     76  if (po == NULL) return 0;
     77  else return 1;
     78}
     79
     80template <class T>
     81int FITS_SphereThetaPhi<T>::CheckReadability(FitsInOutFile& is)
     82{
     83  if (is.CurrentHDUType() !=  BINARY_TBL ) return 0;
     84  string key;
     85  key = "PIXTYPE";
     86  if ( is.KeyValue(key) != "TETAFI")  return 0;
     87  key = "Content";
     88  if ( is.KeyValue(key) != "SphereThetaPhi")  return 0;
     89 
     90  vector<string> colnames;
     91  vector<int> coltypes;
     92  vector<long> repcnt;
     93  vector<long> width;
     94  long ncols = is.GetColInfo(colnames, coltypes, repcnt, width);
     95  if (ncols < 1) return 0;
     96  T x;
     97  if (coltypes[0] == FitsTypes::DataType(x)) return 2 ;
     98  else return 1;
     99}
     100
     101template <class T>
     102FitsHandlerInterface* FITS_SphereThetaPhi<T>::Clone()
     103{
     104  return new FITS_SphereThetaPhi<T>() ;
     105}
     106
    70107
    71108template <class T>
     
    100137  dvl["Content"]= "SphereThetaPhi";
    101138  dvl.SetComment("Content", "name of SOPHYA object");
     139  dvl["SOPCLSNM"]= "SOPHYA::SphereThetaPhi<T>";
     140  dvl.SetComment("SOPCLSNM", "SOPHYA class name");
    102141 
    103142  // On ecrit les dataBlocks
     
    116155  Noms[2] = "CumulPixParBande";
    117156  Noms[3] = "ThetaBande";
    118   string extname("SIMULATION");
    119 
     157  //string extname("SIMULATION");
     158  string extname = os.NextExtensionName();
    120159
    121160  string Type;
  • trunk/SophyaExt/FitsIOServer/fitsspherethetaphi.h

    r1752 r2897  
    2626virtual AnyDataObj* DataObj();
    2727virtual void        SetDataObj(AnyDataObj & o);
     28
     29virtual int         CheckHandling(AnyDataObj & o) ;
     30virtual int         CheckReadability(FitsInOutFile& is);
     31virtual FitsHandlerInterface* Clone();
    2832
    2933void Mollweide_picture_projection(char flnm[]);
Note: See TracChangeset for help on using the changeset viewer.