// file: $isip_ifc/class/algo/Constant/const_00.cc
// version: $Id: const_00.cc 10532 2006-03-29 21:26:30Z raghavan $
//

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

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

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

  // assign data from the input Constant object
  //
  algorithm_d = arg_a.algorithm_d;
  implementation_d = arg_a.implementation_d;
  data_type_d = arg_a.data_type_d;
  filename_d.assign(arg_a.filename_d);
  out_filename_mode_d = arg_a.out_filename_mode_d;
  data_exist_d = arg_a.data_exist_d;  
  return AlgorithmBase::assign(arg_a);
}

// method: eq
//
// arguments:
//  const Constant& 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 Constant::eq(const Constant& arg_a) const {

  // compare the data members
  //
  if ((algorithm_d != arg_a.algorithm_d) ||
      (implementation_d != arg_a.implementation_d) ||
      !(filename_d.eq(arg_a.filename_d)) ||
      out_filename_mode_d != arg_a.out_filename_mode_d ||
      (data_type_d != arg_a.data_type_d) ||
      (data_exist_d != arg_a.data_exist_d)) {
    return false;
  }

  // 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 Constant::clear(Integral::CMODE ctype_a) {
  
  // reset the data members unless the mode is RETAIN
  //
  if (ctype_a != Integral::RETAIN) {

    // clear the design parameters
    //
    algorithm_d = DEF_ALGORITHM;
    implementation_d = DEF_IMPLEMENTATION;  
    out_filename_mode_d = DEF_OUT_FILENAME_MODE;
    data_type_d = AlgorithmData::DEF_DTYPE;
    data_exist_d = DEF_DATA_EXIST;
  }
  
  // exit gracefully
  //
  return AlgorithmBase::clear(ctype_a);
}

//---------------------------------------------------------------------------
//
// class-specific public methods:
//  public methods required by the AlgorithmBase interface contract
//
//---------------------------------------------------------------------------

// method: assign
//
// arguments:
//  const AlgorithmBase& arg: (input) object to be assigned
//
// return: a boolean value indicating status
//
// this method assigns the input algorithm object to the current object.
//
boolean Constant::assign(const AlgorithmBase& arg_a) {

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

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

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

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

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

// method: init
//
// arguments: none
//
// return: a boolean value indicating status
//
// this method precomputes various constants used in this class
// 
boolean Constant::init() {
  
  // check algorithm: DATA
  //
  if (algorithm_d == DATA) {
    // no initialization needed
  }
  
  is_valid_d = true;
  
  // exit gracefully
  //
  return true;
}

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

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

// constants: i/o related constants
//
const String Constant::DEF_PARAM(L"");
const String Constant::DEF_FILENAME(L"diagnose_file.sof");
const String Constant::PARAM_ALGORITHM(L"algorithm");
const String Constant::PARAM_IMPLEMENTATION(L"implementation");
const String Constant::PARAM_OUT_FILENAME_MODE(L"out_filename_mode");
const String Constant::PARAM_DATATYPE(L"datatype"); 
const String Constant::PARAM_FILENAME(L"filename");
const String Constant::PARAM_CHANNEL(L"channels");
const String Constant::PARAM_CHANNEL_INDEX(L"channel_index");  

// constants: default values of the class data
//

// constants: name map(s) for the enumerated values
//
const NameMap Constant::ALGO_MAP(L"DATA");
const NameMap Constant::IMPL_MAP(L"READ, WRITE");
const NameMap Constant::OUT_FILENAME_MODE_MAP(L"NORMAL, TEMPORARY");

// static instantiations: memory manager and hash table
//
MemoryManager Constant::mgr_d(sizeof(Constant), Constant::name());
HashTable<String, String> Constant::hash_files_d;
