// file: $isip/class/search/LexialTree/lex_00.cc
// version: $Id: lex_00.cc 8818 2002-11-19 22:32:57Z parihar $
//

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

// method: default constructor
//
// arguments: none
//
// return: none
//
// this is the default constructor for the LexicalTree class
//
LexicalTree::LexicalTree() {

  // initialize pointers and values
  //
  root_vert_d = (GVLexicalNode*)NULL;
  implementation_d = LexicalTree::DEF_IMPLEMENTATION;
  
  // set the allocation mode of the parent class
  //
  DiGraph<LexicalNode>::setAllocationMode(USER);
}

// method: copy constructor
//
// arguments:
//  const LexicalTree& copy_node: (input) node to copy
//
// return: none
//
// this is the copy constructor for the LexicalTree class
//
LexicalTree::LexicalTree(const LexicalTree& copy_tree_a) {

  // initialize pointers and values
  //
  root_vert_d = (GVLexicalNode*)NULL;
  term_weight_d = 0;

  // set the allocation mode of the parent class
  //
  DiGraph<LexicalNode>::setAllocationMode(USER);

  // assign the node
  //
  assign(copy_tree_a);
}

// method: assign
//
// arguments:
//  const LexicalTree& copy_tree_a: (input) tree to copy
//
// return: logical error status
//
// assign tree from the copy
//
boolean LexicalTree::assign(const LexicalTree& copy_tree_a) {

  // copy the pointers
  //
  root_vert_d = copy_tree_a.root_vert_d;
  algorithm_d = copy_tree_a.algorithm_d;
  implementation_d = copy_tree_a.implementation_d;
  
  // copy the graph, call its base class assign method
  //
  DiGraph<LexicalNode>::assign((DiGraph<LexicalNode>&)copy_tree_a);

  // exit gracefully
  //
  return true;
}

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

  // clear the pointers, the memory of Statistical models is managed by
  // SearchLevel class
  //
  root_vert_d = (GVLexicalNode*)NULL;
  term_weight_d = 0;
  algorithm_d = LexicalTree::DEF_ALGORITHM;
  implementation_d = LexicalTree::DEF_IMPLEMENTATION;
  
  // clear the DiGraph, Lexical tree always work as user mode
  //
  DiGraph<LexicalNode>::clear(Integral::RESET);
  
  // exit gracefully
  //
  return true;
}

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

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

// constants: required constants such as class name
//
const String LexicalTree::CLASS_NAME(L"LexicalTree");

// constants: i/o related constants
//
const String LexicalTree::DEF_PARAM(L"LexicalTree");

// static instantiations: memory manager and debug level
//
MemoryManager LexicalTree::mgr_d(sizeof(LexicalNode), name());
Integral::DEBUG LexicalTree::debug_level_d = Integral::NONE;
