// file: $isip/class/algo/AlgorithmContainer/actn_00.cc
// version: $Id: actn_00.cc 8252 2002-06-29 18:05:02Z picone $
//

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

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

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

  // set all the data
  //
  algorithm_d = arg_a.algorithm_d;
  implementation_d = arg_a.implementation_d;
  variable_d.assign(arg_a.variable_d);
  graph_tag_d = arg_a.graph_tag_d;

  // call the base assign method
  //
  return AlgorithmBase::assign(arg_a);
}

// 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 AlgorithmContainer::clear(Integral::CMODE ctype_a) {

  // for retain mode, we do nothing
  //
  if (ctype_a != Integral::RETAIN) {
  
    algorithm_d = DEF_ALGORITHM;
    implementation_d = DEF_IMPLEMENTATION;
    graph_tag_d = DEF_GRAPH_TAG;

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

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

  if (typeid(arg_a) == typeid(AlgorithmContainer)) {
    return assign((AlgorithmContainer&)arg_a);
  }
  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
//
boolean AlgorithmContainer::eq(const AlgorithmBase& arg_a) const {

  if (typeid(arg_a) == typeid(AlgorithmContainer)) {
    return eq((AlgorithmContainer&)arg_a);
  }
  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 AlgorithmContainer::CLASS_NAME(L"AlgorithmContainer");

// constants: i/o related constants
//
const String AlgorithmContainer::DEF_PARAM(L"");
const String AlgorithmContainer::PARAM_ALGORITHM(L"algorithm");
const String AlgorithmContainer::PARAM_IMPLEMENTATION(L"implementation");
const String AlgorithmContainer::PARAM_GRAPH_TAG(L"graph_tag");
const String AlgorithmContainer::PARAM_VARIABLE(L"variable");

// constants: NameMap(s) for the enumerated values
//
const NameMap AlgorithmContainer::ALGO_MAP(L"SUB_GRAPH");
const NameMap AlgorithmContainer::IMPL_MAP(L"EXPAND");

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

