// file: $isip/class/search/SearchNode/snod_05.cc
//

// isip include files
//
#include "SearchNode.h"
#include <Trace.h>
#include <Instance.h>

// method: assign
//
// arguments:
//  const SearchNode& copy_node: (input) node to copy
//
// return: logical error status
//
// assign SearchNode from the copy
//
boolean SearchNode::assign(const SearchNode& copy_node_a) {

  // copy the pointers
  //
  model_id_d = copy_node_a.model_id_d;
  stat_model_d = copy_node_a.stat_model_d;
  level_d = copy_node_a.level_d;
  lex_tree_d = copy_node_a.lex_tree_d;
  
  // copy the symbol
  //
  symbol_id_d.assign(copy_node_a.symbol_id_d);

  // exit gracefully
  //
  return true;
}

// method: clear
//
// arguments:
//  Integral::CMODE cmode: (input) clear mode
//
// return: logical error status
//
// clear the contents of the SearchNode
//
boolean SearchNode::clear(Integral::CMODE cmode_a) {

  // clear the pointers, the memory of Statistical models is managed by
  // SearchLevel class
  //
  model_id_d = DEF_MODEL_ID;
  stat_model_d = (StatisticalModel*)NULL;
  level_d = (SearchLevel*)NULL;
  lex_tree_d = (LexicalTree*)NULL;

  // clear the symbol
  //
  symbol_id_d.clear(cmode_a);

  // clear the linked list of traces and instances
  //
  traces_d.clear(cmode_a);
  instances_d.clear(cmode_a);  
  
  // reset the values
  //
  timestamp_d = -1;

  // exit gracefully
  //
  return true;
}

// method: eq
//
// arguments:
//  const SearchNode& compare_node: (input) SearchNode to compare
//
// return: true if the SearchNodes are equivalent, else false
//
// compare two SearchNodes. they are equivalent if they have equivalent history
// objects
//
boolean SearchNode::eq(const SearchNode& compare_node_a) const {

  // compare the address
  //
  return (this == &compare_node_a);
}
