// file: $isip/class/algo/Statistics/stat_00.cc
// version: $Id: stat_00.cc 8314 2002-07-09 02:19:50Z picone $
//

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

// method: default constructor
//
// arguments:
//  ALGORITHM algorithm: (input) algorithm used in Statistics
//  IMPLEMENTATION implementation: (input) implementation name
//
// return: none
//
Statistics::Statistics(ALGORITHM algorithm_a,
		       IMPLEMENTATION implementation_a) {
  
  // initialize protected data
  //
  algorithm_d = algorithm_a;
  implementation_d = implementation_a;
  is_calculated_d = false;

  // exit gracefully
  //
}

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

  // assign protected data
  //
  algorithm_d = arg_a.algorithm_d;
  implementation_d = arg_a.implementation_d;

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

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

  if (algorithm_d != arg_a.algorithm_d) {
    return false;
  }
  if (implementation_d != arg_a.implementation_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 to the default values
//
boolean Statistics::clear(Integral::CMODE ctype_a) {

  // reset all protected data
  //
  if (ctype_a != Integral::RETAIN) {
    algorithm_d = DEF_ALGORITHM;
    implementation_d = DEF_IMPLEMENTATION;
  }

  // call the base clear method
  //
  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
// Statistics object, if the input algorithm object is not an Statistics
// object, it returns an error
//
boolean Statistics::assign(const AlgorithmBase& arg_a) {

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

  // case: other
  //  if the input algorithm object is not a Statistics object, return
  //  an 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 Statistics object is identical
// to the input algorithm object, if the input algorithm object is not
// a Statistics object, it returns an error
//
boolean Statistics::eq(const AlgorithmBase& arg_a) const {

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

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

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

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

// constants: i/o related constants
//
const String Statistics::DEF_PARAM(L"");
const String Statistics::PARAM_ALGORITHM(L"algorithm");
const String Statistics::PARAM_IMPLEMENTATION(L"implementation");
const String Statistics::PARAM_CMODE(L"compute_mode");
const String Statistics::PARAM_DMODE(L"data_mode");

// constants: NameMap(s) for the enumerated values
//
const NameMap Statistics::ALGO_MAP(L"MINIMUM, MINIMUM_MAG, MAXIMUM, MAXIMUM_MAG, MEAN, MEDIAN, VARIANCE, STDEV, SKEW, KURTOSIS");
const NameMap Statistics::IMPL_MAP(L"LINEAR");

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

