// C++ code Copyright (C) David R. Evans G4AMJ/NQ0I

#ifndef BDRH
#define BDRH

#include <data.h>

class edr_record;

// classes for browse data records

// ****************************  bdr_record  ***************************
class bdr_record : public data_record
{ // Originally I had the following as octets. However, in transcribing
// the data to CD-ROM, PDS messed up and made them int16s.
int16 _sc_mode, _start_channel, _end_channel;
  
public:
  bdr_record(void);
  ~bdr_record(void) { }
  void operator=(char*);        // ASCII read
  void operator=(FILE*);        // binary read
  
  reveal(int, min_valid_channel_nr, _start_channel);
  reveal(int, max_valid_channel_nr, _end_channel);
  reveal(int, n_channels, _end_channel - _start_channel + 1);
  reveal(int, sc_mode, _sc_mode);

  int16 datum(const int s, const int n) const;
};

// ************************  bdr_file  ****************************
class bdr_file : public data_file
{ int32 _get_file_size(void);
  
  int32 ** start_of_record_index;
  
public:
  bdr_file(DREstring& filename, const char* mode = "rb" );
  ~bdr_file(void); 

  void read(GMDR&, const int rec_nr = -1);
  void read(bdr_record&, const int rec_nr = -1);
  void read(edr_record&, const int rec_nr = -1);
  uint32 size(void);
};

// binary bdr file
// ************************  bbdr_file  ***************************
class bbdr_file : public data_file
{ int32 _get_file_size(void);

  int32* start_of_record_index;
  
public:
  bbdr_file(DREstring filename, const char* mode = "rb" );
  ~bbdr_file(void) 
    { destroy_array(start_of_record_index); }

  void read(GMDR&, const int rec_nr = -1);
  void read(bdr_record&, const int rec_nr = -1);
  void read(edr_record&, const int rec_nr = -1);
  uint32 size(void);  
};

#endif




