// file: $isip/class/algo/Output/out_00.cc
// version: $Id: out_00.cc 9236 2003-06-23 18:12:22Z gao $
//

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

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

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

  // assign data from the input Output object
  //
  algorithm_d = arg_a.algorithm_d;
  implementation_d = arg_a.implementation_d;
  output_basename_d = arg_a.output_basename_d;  
  output_extension_d = arg_a.output_extension_d;
  output_suffix_d = arg_a.output_suffix_d;  

  output_directory_d = arg_a.output_directory_d;
  output_preserve_d = arg_a.output_preserve_d;
  
  debug_level_d = arg_a.debug_level_d;
  
  audio_output_d.assign(arg_a.audio_output_d);
  feature_output_d.assign(arg_a.feature_output_d);
  
  return AlgorithmBase::assign(arg_a);
}

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

  // compare the data members
  //
  if ((algorithm_d != arg_a.algorithm_d) ||
      (implementation_d != arg_a.implementation_d) ||
      (!output_basename_d.eq(arg_a.output_basename_d)) ||
      (!output_extension_d.eq(arg_a.output_extension_d)) ||
      (!output_directory_d.eq(arg_a.output_directory_d)) ||
      (!output_preserve_d.eq(output_preserve_d)) ||
      (!output_suffix_d.eq(arg_a.output_suffix_d)) ||      
      (!(audio_output_d.eq(arg_a.audio_output_d))) ||
      (!(feature_output_d.eq(arg_a.feature_output_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 Output::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;  
  }

  audio_output_d.clear(ctype_a);
  feature_output_d.clear(ctype_a);
  
  // 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 Output::assign(const AlgorithmBase& arg_a) {

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

  // case: other
  //  if the input algorithm object is not an Output 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 Output object is identical
// to the input algorithm object.
//
boolean Output::eq(const AlgorithmBase& arg_a) const {

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

  // case: other
  //  if the input algorithm object is not an Output 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 Outputs used in this class
// 
boolean Output::init() {

  // check algorithm: DATA
  //
  if (algorithm_d == DATA) {
    // no initialization needed
  }

  output_filename_d.clear();

  transformName();
  
  is_valid_d = true;
  
  // exit gracefully
  //
  return true;
}

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

// Outputs: class name
//
const String Output::CLASS_NAME(L"Output");

// constants: default arguments
//

// constants: i/o related constants
//
const String Output::DEF_PARAM(L"");
const String Output::PARAM_ALGORITHM(L"algorithm");
const String Output::PARAM_IMPLEMENTATION(L"implementation");
const String Output::PARAM_BASENAME(L"basename");
const String Output::PARAM_DMODE(L"data_mode");
const String Output::PARAM_AUDIO_OUTPUT(L"audio_output");
const String Output::PARAM_FEATURE_OUTPUT(L"feature_output");

// constants: default values of the class data
//
const String Output::DEF_FILENAME(L"diagnose_file.sof");
const String Output::DEF_TMP_FILE(L"__tmp_output");

// constants: name map(s) for the enumerated values
//
const NameMap Output::ALGO_MAP(L"DATA");
const NameMap Output::IMPL_MAP(L"FEATURES, SAMPLED_DATA");

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