// file: dec_lat_0.cc
//
 
// isip include files
//
#include "decoder.h"
#include "decoder_constants.h"
 
// method: read_lattice_cc
//
// arguments:
//  FILE* fp: (input) file pointer
//  
// return: a logical_1 indicating status
//
// this method reads in the lattice data from file into an lattice
// object, and then compresses it into a compact form
//
logical_1 Decoder::read_lattice_cc(FILE* fp_a, logical_1 compact_a) {

  // check file
  //
  if (fp_a == (FILE*)NULL) {
    error_handler_cc((char_1*)"read_lattice_cc",
		     (char_1*)"NULL input file pointer");
  }
  
  // initialize lattice if not done so
  //
  if (lattice_d == (Lattice*)NULL) {
    delete lattice_d;
    lattice_d = new Lattice();
  }

  // read the lattice from file
  //
  lattice_d->read_lattice_cc(fp_a, lexicon_d);


  if (compact_a == ISIP_TRUE) {

    // now compact this lattice
    //
    Lattice* newlat = (Lattice*)NULL;
    lattice_d->reduce_lattice_cc(newlat);
    
    // replace the old lattice with the compact one
    //
    delete lattice_d;
    lattice_d = newlat;
  }

  // exit gracefully
  //
  return ISIP_TRUE;
}
