// file: $isip/class/algo/AlgorithmBase/algb_00.cc
// version: $Id: algb_00.cc 9106 2003-04-22 03:45:24Z parihar $
//

// isip include files
//
#include "AlgorithmBase.h"

//------------------------------------------------------------------------
//
// required public methods
//
//-----------------------------------------------------------------------

// method: constructor
//
// arguments: none
//
// return: none
//
// this is the default constructor
//
AlgorithmBase::AlgorithmBase() {

  // initialize protected data
  //
  cmode_d = DEF_CMODE;
  dmode_d = DEF_DMODE;  
  sample_freq_d = DEF_SAMPLE_FREQUENCY;
  frame_dur_d = DEF_FRAME_DURATION;
  signal_duration_d = DEF_SIGNAL_DURATION;
  frame_index_d = DEF_FRAME_INDEX;
  num_channels_d = DEF_NUM_CHANNELS;
  leftover_samps_d = DEF_LEFTOVER_SAMPS;
 
  num_elements_d = -1;
  offset_d = 0;

  is_valid_d = false;

  // exit gracefully
  //
}

// method: assign
//
// arguments:
//  const AlgorithmBase& arg: (input) object to assign
//
// return: a boolean value indicating status
//
// this method assigns the input argument to "this".
//
boolean AlgorithmBase::assign(const AlgorithmBase& arg_a) {

  // assign data related to i/o
  //
  debug_level_d = arg_a.debug_level_d;

  // assign other protected data
  //
  cmode_d = arg_a.cmode_d;
  dmode_d = arg_a.dmode_d;
  sample_freq_d = arg_a.sample_freq_d;
  frame_dur_d = arg_a.frame_dur_d;
  signal_duration_d = arg_a.signal_duration_d;
  frame_index_d = arg_a.frame_index_d;
  num_elements_d = arg_a.num_elements_d;
  offset_d = arg_a.offset_d;
  leftover_samps_d = arg_a.leftover_samps_d;
  
  // set valid status to false
  //
  is_valid_d = false;

  // exit gracefully
  //
  return true;
}

// method: eq
//
// arguments:
//  const AlgorithmBase& arg: (input) input object
//
// return: a boolean value indicating status
//
// this method checks if two objects are the same
//
// note that the is_valid flag is not checked as part of
// the equality condition.
//
boolean AlgorithmBase::eq(const AlgorithmBase& arg_a) const {

  // check all internal data
  //
  if (((DebugLevel)debug_level_d != arg_a.debug_level_d) ||
      (is_valid_d != arg_a.is_valid_d) ||
      (sample_freq_d != arg_a.sample_freq_d) ||
      (frame_dur_d != arg_a.frame_dur_d) ||
      (signal_duration_d != arg_a.signal_duration_d) ||
      (frame_index_d != arg_a.frame_index_d) ||      
      (num_elements_d != arg_a.num_elements_d) ||
      (offset_d != arg_a.offset_d) ||
      (cmode_d != arg_a.cmode_d) ||
      (dmode_d != arg_a.dmode_d)) {
    return false;
  }
      
  // exit gracefully
  //
  return true;
}

// method: clear
//
// arguments:
//  Integral::CMODE ctype: (input) clear mode
//
// return: a boolean value indicating status
//
boolean AlgorithmBase::clear(Integral::CMODE ctype_a) {

  // debug level is typically a parameter, so keep its setting in
  // retain mode.
  //
  if (ctype_a != Integral::RETAIN) {
    debug_level_d.assign(Integral::DEF_DEBUG);
  }

  // reset to initial state for all values of ctype_a
  //
  cmode_d = DEF_CMODE;
  dmode_d = DEF_DMODE;
  sample_freq_d = DEF_SAMPLE_FREQUENCY;
  frame_dur_d = DEF_FRAME_DURATION;
  signal_duration_d = DEF_SIGNAL_DURATION;
  frame_index_d = DEF_FRAME_INDEX;
  num_channels_d = DEF_NUM_CHANNELS;

  num_elements_d = -1;
  offset_d = 0;

  is_valid_d = false;

  // exit gracefully
  //
  return true;
}

//---------------------------------------------------------------------------
//
// we define non-integral constants in the default constructor
//      
//---------------------------------------------------------------------------

// constants: class name
//
const String AlgorithmBase::CLASS_NAME(L"AlgorithmBase");

// constants: i/o related constants
//
const String AlgorithmBase::PARAM_DBGL(L"debug_level");

// constants: name map for enum
//
const NameMap AlgorithmBase::CMODE_MAP(L"FRAME_INTERNAL, CROSS_FRAME, ACCUMULATE");
const NameMap AlgorithmBase::DMODE_MAP(L"FRAME_BASED, SAMPLE_BASED");

