// file: $isip/class/search/Instance/inst_07.cc
// version: $Id: inst_07.cc 9347 2003-11-26 20:46:15Z alphonso $
//

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

// method: eq
//
// arguments:
//  const Instance& instance: (input) instance to compare
//
// return: true if the instances are equivalent, else false
//
// compare two instances and determine if they are equivalent
//
boolean Instance::eq(const Instance& instance_a) const {

  // compare the history pointers
  //
  if (history_d != instance_a.history_d) {
    return false;
  }

  // compare the symbol pointers
  //
  if (symbol_d != instance_a.symbol_d) {
    return false;
  }

  // compare the nsymbols
  //
  if ((long)nsymbol_length_d > 0) {
    
    for (long i = 0; i < (long)nsymbol_length_d; i++) {
      if (nsymbol_d[i] != instance_a.nsymbol_d[i]) {
	return false;
      }
    }
  }
  
  // if we reached this far then they must be equal
  //
  return true;  
}

// method: setHistory
//
// arguments:
//  const History* new_hist: (input) the history to copy
//
// return: a boolean indicating status
//
// this method sets the instance's history to the input history
//
boolean Instance::setHistory(const History* new_hist_a) {

  // set the history
  //
  return (history_d = const_cast<History *>(new_hist_a));
}

// method: getHistory
//
// arguments: none
//
// return: a boolean indicating status
//
// this method gets the instance's history
//
History* Instance::getHistory() const {

  // get the history
  //
  return history_d;
}

// method: setSymbol
//
// arguments:
//  const Symbol& new_symbol: (input) the symbol to copy
//
// return: a boolean indicating status
//
// this method sets the instance's symbol to the input symbol
//
boolean Instance::setSymbol(const Context* new_symbol_a) {

  // set the symbol
  //
  return (symbol_d = const_cast<Context *>(new_symbol_a));
}

// method: getSymbol
//
// arguments: none
//
// return: a boolean indicating status
//
// this method gets the instance's symbol
//
Context* Instance::getSymbol() const {

  // get the symbol
  //
  return symbol_d;
}

// method: setSymbolStack
//
// arguments:
//  const History* new_stack: (input) the symbol stack to copy
//
// return: a boolean indicating status
//
// this method sets the instance's symbol stack to the input symbol stack
//
boolean Instance::setSymbolStack(const History* new_stack_a) {

  // set the history
  //
  return (symbol_stack_d = const_cast<History *>(new_stack_a));
}

// method: getSymbolStack
//
// arguments: none
//
// return: a boolean indicating status
//
// this method gets the instance's symbol stack
//
History* Instance::getSymbolStack() const {

  // get the symbol stack
  //
  return symbol_stack_d;
}
