Ignore:
Timestamp:
09/08/11 19:35:40 (13 years ago)
Author:
ShinnosukeKawakami
Message:

merged parallel branch to trunk

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src

  • trunk/src/FillerWrapper.h

    r1904 r2289  
    4545      throw(AipsError("File does not exist"));
    4646    }
    47     filler_ = new PKSFiller(stable_);
    48     if (filler_->open(filename, rec)) {
    49       //    if (filler_->open(filename)) {
    50       attached_ = true;
    51       return;
     47    int fileType = dataType( filename ) ;
     48    if ( fileType == 0 ) {
     49      filler_ = new PKSFiller(stable_);
     50      if (filler_->open(filename, rec)) {
     51        attached_ = true;
     52        return;
     53      }
    5254    }
    53     filler_ = new NROFiller(stable_);
    54     if (filler_->open(filename, rec)) {
    55       //    if (filler_->open(filename)) {
    56       attached_ = true;
    57       return;
     55    else if ( fileType == 1 ) {
     56      filler_ = new NROFiller(stable_);
     57      if (filler_->open(filename, rec)) {
     58        attached_ = true;
     59        return;
     60      }
    5861    }
    5962    filler_ = 0;
     
    8184private:
    8285
     86  int dataType( const std::string &filename ) {
     87    int ret = -1 ;
     88    int pks = 0 ;
     89    int nro = 1 ;
     90    casa::File file( filename ) ;
     91    if ( file.isDirectory() )
     92      ret = pks ;
     93    else if ( file.isReadable() ) {
     94      FILE *f = fopen( filename.c_str(), "r") ;
     95      char buf[8] ;
     96      fread( buf, 6, 1, f ) ;
     97      fclose( f ) ;
     98      buf[7]='\0' ;
     99      // NRO data has two types:
     100      //  1) specific binary data for OTF observation
     101      //  2) (pseudo-)FITS data that doesn't have primary HDU
     102      // So, one can distinguish NRO and non-NRO data by examining
     103      // first keyword name.
     104      if ( casa::String( buf ) == "SIMPLE" ) {
     105        ret = pks ;
     106      }
     107      else {
     108        ret = nro ;
     109      }
     110    }
     111    return ret ;
     112  }
     113
    83114  FillerWrapper();
    84115  FillerWrapper(const FillerWrapper&);
Note: See TracChangeset for help on using the changeset viewer.