Changeset 2766


Ignore:
Timestamp:
02/07/13 18:08:16 (12 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No

Module(s): Module Names change impacts.

Description: Describe your changes here...

Use CountedPtr for NRODataRecord object instead of raw C pointer.


Location:
trunk/external-alma/atnf/PKSIO
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/external-alma/atnf/PKSIO/NRODataset.cc

    r2765 r2766  
    187187}
    188188
    189 void NRODataset::convertEndian( NRODataRecord *r )
    190 {
    191   convertEndian( r->ISCAN ) ;
    192   convertEndian( r->DSCX ) ;
    193   convertEndian( r->DSCY ) ;
    194   convertEndian( r->SCX ) ;
    195   convertEndian( r->SCY ) ;
    196   convertEndian( r->PAZ ) ;
    197   convertEndian( r->PEL ) ;
    198   convertEndian( r->RAZ ) ;
    199   convertEndian( r->REL ) ;
    200   convertEndian( r->XX ) ;
    201   convertEndian( r->YY ) ;
    202   convertEndian( r->TEMP ) ;
    203   convertEndian( r->PATM ) ;
    204   convertEndian( r->PH2O ) ;
    205   convertEndian( r->VWIND ) ;
    206   convertEndian( r->DWIND ) ;
    207   convertEndian( r->TAU ) ; 
    208   convertEndian( r->TSYS ) ;
    209   convertEndian( r->BATM ) ;
    210   convertEndian( r->LINE ) ;
     189void NRODataset::convertEndian( NRODataRecord &r )
     190{
     191  convertEndian( r.ISCAN ) ;
     192  convertEndian( r.DSCX ) ;
     193  convertEndian( r.DSCY ) ;
     194  convertEndian( r.SCX ) ;
     195  convertEndian( r.SCY ) ;
     196  convertEndian( r.PAZ ) ;
     197  convertEndian( r.PEL ) ;
     198  convertEndian( r.RAZ ) ;
     199  convertEndian( r.REL ) ;
     200  convertEndian( r.XX ) ;
     201  convertEndian( r.YY ) ;
     202  convertEndian( r.TEMP ) ;
     203  convertEndian( r.PATM ) ;
     204  convertEndian( r.PH2O ) ;
     205  convertEndian( r.VWIND ) ;
     206  convertEndian( r.DWIND ) ;
     207  convertEndian( r.TAU ) ; 
     208  convertEndian( r.TSYS ) ;
     209  convertEndian( r.BATM ) ;
     210  convertEndian( r.LINE ) ;
    211211  for ( int i = 0 ; i < 4 ; i++ )
    212     convertEndian( r->IDMY1[i] ) ;
    213   convertEndian( r->VRAD ) ;
    214   convertEndian( r->FREQ0 ) ;
    215   convertEndian( r->FQTRK ) ;
    216   convertEndian( r->FQIF1 ) ;
    217   convertEndian( r->ALCV ) ;
     212    convertEndian( r.IDMY1[i] ) ;
     213  convertEndian( r.VRAD ) ;
     214  convertEndian( r.FREQ0 ) ;
     215  convertEndian( r.FQTRK ) ;
     216  convertEndian( r.FQIF1 ) ;
     217  convertEndian( r.ALCV ) ;
    218218  for ( int i = 0 ; i < 2 ; i++ )
    219219    for ( int j = 0 ; j < 2 ; j++ )
    220       convertEndian( r->OFFCD[i][j] ) ;
    221   convertEndian( r->IDMY0 ) ;
    222   convertEndian( r->IDMY2 ) ;
    223   convertEndian( r->DPFRQ ) ;
    224   convertEndian( r->SFCTR ) ;
    225   convertEndian( r->ADOFF ) ;
     220      convertEndian( r.OFFCD[i][j] ) ;
     221  convertEndian( r.IDMY0 ) ;
     222  convertEndian( r.IDMY2 ) ;
     223  convertEndian( r.DPFRQ ) ;
     224  convertEndian( r.SFCTR ) ;
     225  convertEndian( r.ADOFF ) ;
    226226}
    227227
    228228void NRODataset::releaseRecord()
    229229{
    230   if ( record_ ) {
     230  if ( !record_.null() ) {
    231231    record_ = NULL ;
    232232  }
     
    248248
    249249  if ( i == dataid_ ) {
    250     return record_ ;
     250    return &(*record_) ;
    251251  }
    252252
     
    267267  }
    268268
    269   return record_ ;
     269  return &(*record_) ;
    270270}
    271271
     
    285285  //cout << "NRODataset::fillRecord()  sizeof(NRODataRecord) = " << sizeof( NRODataRecord ) << " byte" << endl ;
    286286  fseek( fp_, offset, SEEK_SET ) ;
    287   if ( (int)fread( record_, 1, SCAN_HEADER_SIZE, fp_ ) != SCAN_HEADER_SIZE ) {
     287  if ( (int)fread( &(*record_), 1, SCAN_HEADER_SIZE, fp_ ) != SCAN_HEADER_SIZE ) {
    288288    //cerr << "Failed to read scan header: " << i << endl ;
    289289    LogIO os( LogOrigin( "NRODataset", "fillRecord()", WHERE ) ) ;
     
    299299
    300300  if ( same_ == 0 ) {
    301     convertEndian( record_ ) ;
     301    convertEndian( *record_ ) ;
    302302  }
    303303
     
    358358  //
    359359
    360   NRODataRecord *record = getRecord( i ) ;
     360  const NRODataRecord *record = getRecord( i ) ;
    361361
    362362  const int bit = IBIT ;   // fixed to 12 bit
     
    467467  //cout << "NRODataset::getIndex()  start" << endl ;
    468468  //
    469   NRODataRecord *record = getRecord( irow ) ;
    470   string str = record->ARRYT ;
     469  const NRODataRecord *record = getRecord( irow ) ;
     470  const string str = record->ARRYT ;
    471471  // DEBUG
    472472  //cout << "NRODataset::getIndex()  str = " << str << endl ;
     
    541541double NRODataset::getStartIntTime( int i )
    542542{
    543   NRODataRecord *record = getRecord( i ) ;
    544 
    545   char *t = record->LAVST ;
     543  const NRODataRecord *record = getRecord( i ) ;
     544
     545  const char *t = record->LAVST ;
    546546  return getMJD( t ) ;
    547547}
    548548
    549 double NRODataset::getMJD( char *time )
     549double NRODataset::getMJD( const char *time )
    550550{
    551551  // TODO: should be checked which time zone the time depends on
     
    592592      f[1] = f[1] - f[0] * f[2] ;
    593593    }
    594     NRODataRecord *record = getRecord( i ) ;
     594    const NRODataRecord *record = getRecord( i ) ;
    595595    f[3] = record->FREQ0 ;
    596596    if ( v.size() == 0 ) {
     
    629629  vector<double> v( 3, 0.0 ) ;
    630630
    631   NRODataRecord *record = getRecord( i ) ;
     631  const NRODataRecord *record = getRecord( i ) ;
    632632  string arryt = string( record->ARRYT ) ;
    633633  uInt ib = getArrayId( arryt ) ;
  • trunk/external-alma/atnf/PKSIO/NRODataset.h

    r2764 r2766  
    4242#include <casa/Logging/LogIO.h>
    4343#include <casa/Containers/Record.h>
     44#include <casa/Utilities/CountedPtr.h>
    4445#include <atnf/PKSIO/NRODataRecord.h>
    4546#include <casa/namespace.h>
     
    194195  virtual double getStartIntTime( int i ) ;
    195196  virtual double getScanTime( int i ) ;
    196   virtual double getMJD( char *time ) ;
     197  virtual double getMJD( const char *time ) ;
    197198  virtual std::vector<bool> getIFs() ;
    198199  virtual std::vector<double> getFrequencies( int i ) ;
     
    214215
    215216  // Endian conversion for NRODataRecord
    216   void convertEndian( NRODataRecord *r ) ;
     217  void convertEndian( NRODataRecord &r ) ;
    217218
    218219  // Read char data
     
    500501
    501502  // Data record
    502   NRODataRecord *record_ ;
     503  CountedPtr<NRODataRecord> record_ ;
    503504
    504505  // input filename
  • trunk/external-alma/atnf/PKSIO/NROFITSDataset.cc

    r2763 r2766  
    12251225  vector<double> spec( chmax_, 0.0 ) ;
    12261226  vector<double> specout( chmax_, 0.0 ) ;
    1227   NRODataRecord *record = getRecord( i ) ;
     1227  const NRODataRecord *record = getRecord( i ) ;
    12281228  double scale = record->SFCTR ;
    12291229  double offset = record->ADOFF ;
     
    14151415int NROFITSDataset::getIndex( int irow )
    14161416{
    1417   NRODataRecord *record = getRecord( irow ) ;
     1417  const NRODataRecord *record = getRecord( irow ) ;
    14181418  string str = record->ARRYT ;
    14191419  string::size_type pos = str.find( " " ) ;
  • trunk/external-alma/atnf/PKSIO/NROReader.cc

    r2764 r2766  
    345345{
    346346  Vector<Double> v( 2 ) ;
    347   NRODataRecord *record = dataset_->getRecord( i ) ;
     347  const NRODataRecord *record = dataset_->getRecord( i ) ;
    348348  char epoch[5] ;
    349349  strncpy( epoch, (dataset_->getEPOCH()).c_str(), 5 ) ;
     
    479479  freqref = freqRefFromVREF_ ? vref : "REST" ;
    480480  //cout << "freqref = " << freqref << endl ;
    481   NRODataRecord *record = dataset_->getRecord( 0 ) ;
     481  const NRODataRecord *record = dataset_->getRecord( 0 ) ;
    482482  reffreq = record->FREQ0 ; // rest frequency
    483483
     
    520520string NROReader::getScanType( int i )
    521521{
    522   NRODataRecord *record = dataset_->getRecord( i ) ;
     522  const NRODataRecord *record = dataset_->getRecord( i ) ;
    523523  string s = record->SCANTP ;
    524524
Note: See TracChangeset for help on using the changeset viewer.