// file: $isip/class/algo/Prediction/pred_00.cc
// version: $Id: pred_00.cc 7696 2002-02-06 03:17:04Z zheng $
//

// isip include files
//
#include "Prediction.h"
#include <typeinfo>

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

// method: assign
//
// arguments:
//  const Prediction& arg: (input) linear prediction object
//
// return: a boolean value indicating status
//
// this method assign the input object to the current object
//
boolean Prediction::assign(const Prediction& arg_a) {

  // assign the values
  //
  order_d = arg_a.order_d;
  algorithm_d = arg_a.algorithm_d;
  implementation_d = arg_a.implementation_d;
  dyn_range_d = arg_a.dyn_range_d;

  // copy the base class
  //
  return AlgorithmBase::assign(arg_a);
}

// method: eq
//
// arguments:
//  const Prediction& arg: (input) linear prediction object
//
// return: a boolean value indicating status
//
// this method checks whether the current object is identical to the
// input object
//
boolean Prediction::eq(const Prediction& arg_a) const {

  // check the class data
  //
  if (order_d != arg_a.order_d) {
    return false;
  }
  
  if (algorithm_d != arg_a.algorithm_d) {
    return false;
  }
  
  if (implementation_d != arg_a.implementation_d) {
    return false;
  }
  
  if (dyn_range_d != arg_a.dyn_range_d) {
    return false;
  }

  // exit gracefully by checking the base class
  //
  return AlgorithmBase::eq(arg_a);  
}

// method: clear
//
// arguments:
//  Integral::CMODE ctype: (input) clear mode
//
// return: a boolean value indicating status
//
// this method resets the data members 
//
boolean Prediction::clear(Integral::CMODE ctype_a) {

  // clean up memory and reset
  //  
  order_d = DEF_ORDER;
  algorithm_d = DEF_ALGORITHM;
  implementation_d = DEF_IMPLEMENTATION;
  dyn_range_d = DEF_DYN_RANGE;

  // call the base clear method
  //
  return AlgorithmBase::clear(ctype_a);
}

//---------------------------------------------------------------------------
//
// class-specific public methods:  
//  AlgorithmBase interface contract methods
//
//---------------------------------------------------------------------------

// method: assign
//
// arguments:
//  const AlgorithmBase& arg: (input) linear prediction object
//
// return: a boolean value indicating status
//
// this assign method is required for AlgorithmBase interface 
//
boolean Prediction::assign(const AlgorithmBase& arg_a) {
  
  // case: input is a Prediction object
  //  
  if (typeid(arg_a) == typeid(Prediction)) {
    return assign((Prediction&)arg_a);
  }

  // case: other
  //  if the input algorithm object is not a Prediction object, return
  //  an error.
  //  
  else {
    return Error::handle(name(), L"assign", Error::ARG, __FILE__, __LINE__);
  }

  // exit gracefully
  //
  return true;
}

// method: eq
//
// arguments:
//  const AlgorithmBase& arg: (input) object to test equality for
//
// return: a boolean value indicating status
//
// this method checks the two objects are equal or not
//
boolean Prediction::eq(const AlgorithmBase& arg_a) const {

  // case: input is a Prediction object
  //  
  if (typeid(arg_a) == typeid(Prediction)) {
    return eq((Prediction&)arg_a);
  }

  // case: other
  //  if the input algorithm object is not a Prediction object, return
  //  an error.
  //  
  else {
    return Error::handle(name(), L"eq", Error::ARG, __FILE__, __LINE__);
  }
  
  // exit gracefully
  //
  return true;
}

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

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

// constants: i/o related constants
//
const String Prediction::DEF_PARAM(L"");
const String Prediction::PARAM_ALGORITHM(L"algorithm");
const String Prediction::PARAM_IMPLEMENTATION(L"implementation");
const String Prediction::PARAM_ORDER(L"order");
const String Prediction::PARAM_DYN_RANGE(L"dynamic_range");

// constants: NameMap(s) for the enumerated values
//
const NameMap Prediction::ALGO_MAP(L"AUTOCORRELATION, COVARIANCE, LATTICE, REFLECTION, LOG_AREA_RATIO");
const NameMap Prediction::IMPL_MAP(L"DURBIN, LEROUX_GUEGUEN, CHOLESKY, BURG, STEP_DOWN, KELLY_LOCHBAUM");

// static instantiations: memory manager
//
MemoryManager Prediction::mgr_d(sizeof(Prediction), Prediction::name());
