// file: dec_read_1.cc
//
 
// isip include files
//
#include "decoder.h"
#include "decoder_constants.h"
 
// method: read_states_cc
//
// arguments:
//  FILE* fp: (input) file pointer
//  
// return: a logical_1 indicating status
//
// this method reads in the states data from file into an array of
// state objects
//
logical_1 Decoder::read_states_cc(FILE* fp_a) {

  // check file
  //
  if (fp_a == (FILE*)NULL) {
    error_handler_cc((char_1*)"read_states_cc",
		     (char_1*)"NULL input file pointer");
  }
  
  // read the number of features and number of states
  //
  fread((void_p)&num_feat_d, sizeof(int_4), 1, fp_a);
  fread((void_p)&num_states_d, sizeof(int_4), 1, fp_a);
  
  // initialize the states
  //
  State::set_num_features_cc(num_feat_d);
  states_d = new State*[num_states_d];
  
  // read state data from file
  //
  for (int_4 i = 0; i < num_states_d; i++) {

    // create state memory
    //
    states_d[i] = new State();

    // read the parameters for this state
    //
    states_d[i]->read_data_cc(fp_a);
  }

  // exit gracefully
  //
  return ISIP_TRUE;
}
