// file: trace.h
//
// this is the header for the path trace class
//

// make sure definitions are only made once
//
#ifndef __ISIP_TRACE
#define __ISIP_TRACE

// isip include files
//
#ifndef __ISIP_INTEGRAL
#include <integral.h>
#endif

#ifndef __ISIP_LEX_NODE
#include <lex_node.h>
#endif

#ifndef __ISIP_HISTORY
#include <history.h>
#endif

#ifndef __ISIP_INSTANCE
#include <instance.h>
#endif

// Trace: a class that is used as the path trace for a
// trace-projection decoder
//
class Trace {
  
  //---------------------------------------------------------------------------
  //
  // protected data
  //
  //---------------------------------------------------------------------------
protected:
  
  // position in the search space
  //
  History* history_d;
  Instance* instance_d;
  Lex_node* lex_next_d;
  
  // other parameters
  //
  int_4 level_d;               // level in the search network hierarchy
  int_4 phone_index_d;         // the actual phone index
  int_4 state_index_d;         // the current state index
  int_4 max_hist_d;            // maximum number of previous histories
  float_4 score_d;             // path probability at this trace

  //---------------------------------------------------------------------------
  //
  // public methods
  //
  //---------------------------------------------------------------------------
public:
  
  // required methods
  //
  char_1* name_cc();
  volatile void error_handler_cc(char_1* mname, char_1* msg);
  logical_1 debug_cc(FILE* fp, char_1* message);
  int_4 size_cc();
  
  // destructors/constructors
  //
  ~Trace();  
  Trace();                                               // default
  Trace(Trace* trace, float_4 score);                    // overloaded
  Trace(Trace& trace);                                   // copy

  // instance information methods
  //
  logical_1 set_inst_cc(Instance* inst) {
    instance_d = inst;
    return ISIP_TRUE;
  }
  
  Instance* get_inst_cc() {
    return instance_d;
  }

  // lexical tree node methods
  //
  logical_1 set_lex_next_cc(Lex_node* lex_next) {
    lex_next_d = lex_next;
    return ISIP_TRUE;
  }
  
  Lex_node* get_lex_next_cc() {
    return lex_next_d;
  }

  // path history methods
  //
  logical_1 set_max_hist_cc(int_4 size) {
    max_hist_d = size;
    return ISIP_TRUE;
  }

  int_4 get_max_hist_cc() {
    return max_hist_d;
  }

  logical_1 set_hist_cc(History* history) {
    history_d = history;
    return history_d->incr_ref_count_cc();
  }

  History* get_hist_cc() {
    return history_d;
  }
  
  logical_1 add_path_cc(History* history, float_4 pscore);
  logical_1 decr_ref_cc() {
    return history_d->decr_ref_count_cc();
  }
  
  logical_1 incr_ref_cc() {
    return history_d->incr_ref_count_cc();
  }
  
  // level methods
  //
  logical_1 set_level_cc(int_4 inst) {
    level_d = inst;
    return ISIP_TRUE;
  }

  int_4 get_level_cc() {
    return level_d;
  }

  logical_1 incr_level_cc() {
    level_d++;
    return ISIP_TRUE;
  }

  // phone index methods
  //
  logical_1 set_phone_ind_cc(int_4 phone) {
    phone_index_d = phone;
    return ISIP_TRUE;
  }
  
  int_4 get_phone_ind_cc() {
    return phone_index_d;
  }

  // state index methods
  //
  logical_1 set_state_ind_cc(int_4 state) {
    state_index_d = state;
    return ISIP_TRUE;
  }
  
  int_4 get_state_ind_cc() {
    return state_index_d;
  }

  // score methods
  //
  logical_1 set_score_cc(float_4 score) {
    score_d = score;
    return ISIP_TRUE;
  }
  
  float_4 get_score_cc() {
    return score_d;
  }
  
  logical_1 incr_score_cc(float_4 incr) {
    score_d += incr;
    return ISIP_TRUE;
  }

  // path methods
  //
  logical_1 project_trace_cc(Trace* trace) {
    return project_trace_cc(trace, (float_4)0);
  }

  logical_1 project_trace_cc(Trace* trace, float_4 score);
  Trace* compare_cc(Trace* trace);
  
  // reset parameters
  //
  logical_1 clear_cc();

  //---------------------------------------------------------------------------
  //
  // private methods
  //
  //---------------------------------------------------------------------------
private:

};

// end of file
// 
#endif
