// file: $isip/class/algo/Cepstrum/cep_00.cc
// version: $Id: cep_00.cc 8845 2002-11-26 20:16:04Z parihar $
//

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

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

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

  // assign all the coefficients
  //
  order_d = arg_a.order_d;
  algorithm_d = arg_a.algorithm_d;
  implementation_d = arg_a.implementation_d;
  ft_d = arg_a.ft_d;
  min_amp_d = arg_a.min_amp_d;
  flag_min_amp_d = arg_a.flag_min_amp_d;
    
  // call the AlgorithmBase assign method
  //
  return AlgorithmBase::assign(arg_a);
}

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

  // compare the data members
  //
  if ((order_d != arg_a.order_d) ||
      (algorithm_d != arg_a.algorithm_d) ||
      (implementation_d != arg_a.implementation_d) ||
      (min_amp_d != arg_a.min_amp_d) ||
      (flag_min_amp_d != arg_a.flag_min_amp_d)) {
    return true;
  }
  
  // exit gracefully
  //
  return true;
}

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

  // clean up memory and reset
  //
  if (ctype_a != Integral::RETAIN) {
    order_d = DEF_ORDER;
    algorithm_d = DEF_ALGORITHM;
    implementation_d = DEF_IMPLEMENTATION;
    min_amp_d = DEF_MIN_AMP;
    flag_min_amp_d = DEF_FLAG_MIN_AMP;
  }

  // call the clear method for fourier transform object
  //
  ft_d.clear(ctype_a);

  // 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) object to assign
//
// return: a boolean value indicating status
//
// this method assigns input object to the current object
//
boolean Cepstrum::assign(const AlgorithmBase& arg_a) {

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

  // case: other
  //  if the input algorithm object is not a Cepstrum object, 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 assign
//
// return: a boolean value indicating status
//
// this method checks whether two cepstrum objects are equal or not
//
boolean Cepstrum::eq(const AlgorithmBase& arg_a) const {

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

  // case: other
  //  if the input algorithm object is not a Cepstrum object, 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 Cepstrum::CLASS_NAME(L"Cepstrum");

// constants: i/o related constants
//
const String Cepstrum::DEF_PARAM(L"");
const String Cepstrum::PARAM_ORDER(L"order");
const String Cepstrum::PARAM_ALGORITHM(L"algorithm");
const String Cepstrum::PARAM_IMPLEMENTATION(L"implementation");
const String Cepstrum::PARAM_MIN_AMP(L"minimum_amplitude");
const String Cepstrum::PARAM_FLAG_MIN_AMP(L"flag_minimum_amplitude");

// constants: NameMap(s) for the enumerated values
//
const NameMap Cepstrum::ALGO_MAP(L"IDCT, IDFT");
const NameMap Cepstrum::IMPL_MAP(L"TYPE_I, TYPE_II, TYPE_III, TYPE_IV, CONVENTIONAL");

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

