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

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

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

#ifndef __ISIP_TRAIN_LATTICE_NODE
#include <train_lattice_node.h>
#endif

#ifndef __ISIP_TRAIN_LEX_NODE
#include <train_lex_node.h>
#endif

#ifndef __ISIP_TRAIN_WORD
#include <train_word.h>
#endif

// Train_Trace: a class that is used as the path trace for the training
// modules
//
class Train_Trace {
  
  //---------------------------------------------------------------------------
  //
  // protected data
  //
  //---------------------------------------------------------------------------
protected:
  
  // pointers to position in the network
  //
  Train_Lattice_node* lat_node_d;           // node in the lattice
  Train_Lex_node* lex_node_d;               // node in the lexical tree
  
  // level in the search network hierarchy
  //
  int_4 level_d;

  // pointer to the current triphone
  //
  int_4 phone_index_d;

  // state index
  //
  uint_1 state_index_d;
  
  // path history information
  //
  Train_Trace** back_ptr_d;            // pointers to the prev traces in path
  int_4 backptr_size_d;                // size of the back-pointer array
  
  // path information
  //
  int_4 frame_index_d;                // frame this trace is in
  float_8 score_d;                    // path probability at this trace
  int_4 ref_count_d;                  // reference count of paths
  logical_1 active_d;                 // active flag for current frame

  // index of the mixture
  //
  int_4 max_mixture_d;

  //---------------------------------------------------------------------------
  //
  // 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
  //
  ~Train_Trace();  
  Train_Trace();                                            // default
  Train_Trace(Train_Trace* trace, float_8 score);           // overloaded
  Train_Trace(Train_Trace& trace);                          // copy

  // reset parameters
  //
  logical_1 clear_cc();

  // mixture methods
  //
  logical_1 set_max_mixture_cc(int_4 max_mix);
  int_4 get_max_mixture_cc();

  // lattice node methods
  //
  logical_1 set_lat_node_cc(Train_Lattice_node* lat_node);
  Train_Lattice_node* get_lat_node_cc();

  // lexical tree node methods
  //
  logical_1 set_lex_node_cc(Train_Lex_node* lex_node);
  Train_Lex_node* get_lex_node_cc();

  // level methods
  //
  logical_1 set_level_cc(int_4 inst);
  int_4 get_level_cc();
  logical_1 incr_level_cc();
  logical_1 incr_level_cc(int_4 incr);

  // phone index methods
  //
  logical_1 set_phone_ind_cc(int_4 phone);  
  int_4 get_phone_ind_cc();

  // state index methods
  //
  logical_1 set_state_ind_cc(uint_1 state_d);  
  uint_1 get_state_ind_cc();  

  // path history methods
  //
  logical_1 set_back_size_cc(int_4 size);
  int_4 get_back_size_cc();
  logical_1 set_back_ptr_cc(Train_Trace** trace);
  Train_Trace** get_back_ptr_cc();
  logical_1 add_back_ptr_cc(Train_Trace* trace);

  // path methods
  //
  logical_1 project_trace_cc(Train_Trace* trace, float_8 score);
  logical_1 project_trace_cc(Train_Trace* trace);
  Train_Trace* compare_cc(Train_Trace* trace);
  
  // frame index methods
  //
  logical_1 set_frame_ind_cc(int_4 frame);  
  int_4 get_frame_ind_cc();
  logical_1 incr_frame_ind_cc(int_4 incr);
  logical_1 incr_frame_ind_cc();

  // score methods
  //
  logical_1 set_score_cc(float_8 score);
  float_8 get_score_cc();
  logical_1 incr_score_cc(float_8 incr);    

  // reference count methods
  //
  logical_1 set_ref_count_cc(int_4 ref);
  int_4 get_ref_count_cc();
  logical_1 incr_ref_count_cc(int_4 incr);
  logical_1 incr_ref_count_cc();
  logical_1 incr_ref_path_cc(int_4 value);

  // active flag methods
  //
  logical_1 set_active_cc(logical_1 val);
  logical_1 get_active_cc();

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

};

// end of file
// 
#endif
