// file: $isip/class/algo/Mask/mask_00.cc
// version: $Id: mask_00.cc 6945 2001-05-08 05:43:27Z roberts $
//

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

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

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

  // assign the algorithm name
  //
  algorithm_d = arg_a.algorithm_d;

  // assign the implementation name
  //
  implementation_d = arg_a.implementation_d;
  
  // assign mask string
  //
  source_d.assign(arg_a.source_d);

  // assign mask vector
  //
  mask_d.assign(arg_a.mask_d);

  // assign AlgorithmBase and exit gracefully
  //
  return AlgorithmBase::assign(arg_a);
}

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

  // compare the data members
  //
  if ((algorithm_d != arg_a.algorithm_d) ||
      (implementation_d != arg_a.implementation_d) ||
      (!source_d.eq(arg_a.source_d))) {
    
    // exit gracefully
    //
    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 Mask::clear(Integral::CMODE ctype_a) {

  // reset the data members unless the mode is RETAIN
  //
  if (ctype_a != Integral::RETAIN) {
    algorithm_d = DEF_ALGORITHM;
    implementation_d = DEF_IMPLEMENTATION;
    mask_d.clear(ctype_a);
    source_d.clear(ctype_a);
  }

  // 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 Mask
// object. if the input algorithm object is not a Mask object, it is
// an error.
//
boolean Mask::assign(const AlgorithmBase& arg_a) {

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

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

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

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

// constants: i/o related constants
//
const String Mask::DEF_PARAM(L"");
const String Mask::PARAM_ALGORITHM(L"algorithm");
const String Mask::PARAM_IMPLEMENTATION(L"implementation");
const String Mask::PARAM_MASK(L"mask");

// constants: NameMap(s) for the enumerated values
//
const NameMap Mask::ALGO_MAP(L"SELECT, REMOVE");
const NameMap Mask::IMPL_MAP(L"INDEX");

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