// file: $isip/class/search/HierarchicalDigraph/HierarchicalDigraph.h
//

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

// isip include files
//
#ifndef ISIP_VECTOR
#include <Vector.h>
#endif

#ifndef ISIP_SEARCH_LEVEL
#include <SearchLevel.h>
#endif

// HierarchicalDigraph: encapsulates the SearchLevel vector
// used to represent a language model.
//
class HierarchicalDigraph : public Vector<SearchLevel> {

  //---------------------------------------------------------------------------
  //
  // public constants
  //
  //---------------------------------------------------------------------------
public:

  // declare the class name
  //
  static const String CLASS_NAME;

  //--------------------------------------------------------------
  //
  // other important constants
  //
  //--------------------------------------------------------------

  enum SOURCE_FORMAT { UNKNOWN = 0, IHD, JSGF, XML, DEF_SRC_FORMAT = IHD };

  // define static NameMap objects
  //
  static const NameMap SRC_MAP;
  
  //----------------------------------------
  //
  // error codes
  //
  //----------------------------------------  

  static const long ERR = 100100;

  //---------------------------------------------------------------------------
  //
  // protected data
  //
  //---------------------------------------------------------------------------
protected:
  
  static Integral::DEBUG debug_level_d;

  SOURCE_FORMAT source_format_d;
  
  // static memory manager
  //
  static MemoryManager mgr_d;

  //---------------------------------------------------------------------------
  //
  // required public methods
  //
  //---------------------------------------------------------------------------
public:

  // method: name
  //
  static const String& name() {
    return CLASS_NAME;
  }

  // other static methods
  //
  static boolean diagnose(Integral::DEBUG debug_level);

  // debug methods
  //
  boolean debug(const unichar* msg) const;

  // method: destructor
  //
  ~HierarchicalDigraph() {}  

  // method: default constructor
  //
  HierarchicalDigraph() {}

  // method: copy constructor
  //
  HierarchicalDigraph(const HierarchicalDigraph& copy) {
    assign(copy);
  }

  // assign methods
  //
  boolean assign(const HierarchicalDigraph& arg);

  // i/o methods
  //
  long sofSize() const;

  boolean read(Sof& sof, long tag, const String& name = CLASS_NAME);

  boolean write(Sof& sof, long tag, const String& name = CLASS_NAME) const;

  // equality methods
  //
  boolean eq(const HierarchicalDigraph& arg) const;

  // memory managements methods
  //
  boolean clear(Integral::CMODE cmode = Integral::DEF_CMODE);

  //-------------------------------------------------------------
  //
  // class-specified set and get methods
  //
  //-------------------------------------------------------------

  // method: getSrcFormat
  //
  SOURCE_FORMAT getSrcFormat() {
    return source_format_d;
  }

  // method: setSrcFormat
  //
  boolean setSrcFormat(SOURCE_FORMAT source_format) {
    source_format_d = source_format;
    return true;
  }
    
};

// end of include file
//
#endif
