// file: $isip/class/search/StackSearch/ssrch_00.cc
// version: $Id: ssrch_00.cc 9173 2003-05-30 02:02:08Z jelinek $
//

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

// method: destructor
//
// arguments: none
//
// return: none
//
// this is the default destructor for the StackSearch class.
//
StackSearch::~StackSearch() {

  // clear the current traces
  //
  clearTraceStorage();
}

// method: default constructor
//
// arguments: none
//
// return: none
//
// this is the default constructor for the StackSearch class.
//
StackSearch::StackSearch() :
  valid_hyps_d(DstrBase::USER) {

  // initialize those data members that need to be initialized
  //
  num_frames_d = ALL_FRAMES;
  current_frame_d = START_FRAME;
  n_best_d = DEF_N_BEST;
  stack_level_d = DEF_STACK_LEVEL;
  evaluation_mode_d = DEF_EVALUATION_MODE;
  decoding_mode_d = DEF_DECODING_MODE;
  score_normalization_d = DEF_SCORE_NORMALIZATION;
  user_requested_no_score_normalization_d = false;
  
  // set the allocation mode for the term hypotheses list
  //
  term_hyps_d.setAllocationMode(DstrBase::USER);
  
  // allocate variables for the stack decoder
  // note: stat_model_scores_d are not allocated yet, because we don't
  // know the number of statistical models. It will be done in
  // initSizes() method
  //
  // there will be one initial stack with index zero
  //
  stacks_d.setLength(MAX_NUM_FRAMES + 1);
  max_stack_scores_d.setLength(MAX_NUM_FRAMES + 1);
  max_frame_scores_d.setDimensions(MAX_NUM_FRAMES, MAX_NUM_LEVELS);
  
  best_valid_score_d = Trace::INACTIVE_SCORE;

  // initialize statistics
  //
  num_traces_gen_d.setLength(MAX_NUM_FRAMES + 1);
  num_traces_vit_prun_d.setLength(MAX_NUM_FRAMES + 1);
  num_traces_beam_prun_d.setLength(MAX_NUM_FRAMES + 1);
  num_eval_d.setLength(MAX_NUM_FRAMES + 1);
  num_avoided_eval_d.setLength(MAX_NUM_FRAMES + 1);
}

// method: copy constructor
//
// arguments:
//  const StackSearch& arg: (input) search to copy
//
// return: none
//
// this is the copy constructor for the StackSearch class
//
StackSearch::StackSearch(const StackSearch& arg_a) :
  valid_hyps_d(DstrBase::USER) {

  // initialize the data members that need it
  //
  clear();

  // set the allocation mode for the term hypotheses list
  //
  term_hyps_d.setAllocationMode(DstrBase::USER);
  
  // assign the search
  //
  assign(arg_a);
}

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

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

// constants: i/o related constants
//
const String StackSearch::DEF_PARAM(L"stack_search");
const String StackSearch::PARAM_DECODING_MODE(L"decoding_mode");
const String StackSearch::PARAM_SCORE_NORMALIZATION(L"score_normalization");
const String StackSearch::PARAM_STACK_LEVEL(L"stack_level");
const String StackSearch::PARAM_MAX_MIN_FILENAME(L"max_min_file");
const String StackSearch::PARAM_SIL_DUR_PENALTY(L"sil_dur_penalty");

// constants: NameMap(s) for the enumerated values
//
const NameMap StackSearch::EVALUATION_MODE_MAP(L"FRAME_EVAL, SEGMENT_EVAL");
const NameMap StackSearch::DECODING_MODE_MAP(L"GLOBAL_STACK, MULTI_STACK, VITERBI");
const NameMap StackSearch::SCORE_NORMALIZATION_MAP(L"NONE, DURATION, NUM_OF_FRAMES");

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

//
// end of file
