// file: $isip/class/pr/LanguageModel/LanguageModel.h // // make sure definitions are only made once // #ifndef ISIP_LANGUAGE_MODEL #define ISIP_LANGUAGE_MODEL #ifndef ISIP_LANGUAGE_MODEL_BASE #include #endif #ifndef ISIP_LANGUAGE_MODEL_UNDEFINED #include #endif // forward class definitions // class LanguageModelIHD; class LanguageModelJSGF; //class LanguageModelXML; // forward class definitions // // LanguageModelBase: defines the minimal interface contract for all // language model classes // class LanguageModel : public LanguageModelBase { //--------------------------------------------------------------------------- // // public constants // //--------------------------------------------------------------------------- public: // define the class name // static const String CLASS_NAME; //-------------------------------------------------------------- // // other important constants // //-------------------------------------------------------------- // define the currently available language model formats // enum ALGORITHM { UNKNOWN = 0, IHD, JSGF, XML, BNF, ABNF, DEF_ALGO = UNKNOWN }; // define the implementation map // enum IMPLEMENTATION { HD, DEF_IMPL = HD }; // define static NameMap objects // static const NameMap ALGO_MAP; static const NameMap IMPL_MAP; //---------------------------------------- // // i/o related constants // //---------------------------------------- static const String PARAM_ALGO; static const String PARAM_IMPL; static const String DEF_PARAM; static const int32 DEF_TAG; //---------------------------------------- // // default values and arguments // //---------------------------------------- // define the default value(s) of the class data // static LanguageModelUndefined NO_LANGUAGE_MODEL; //---------------------------------------- // // error codes // //---------------------------------------- static const int32 ERR = 100102; //--------------------------------------------------------------------------- // // protected data // //--------------------------------------------------------------------------- protected: // a virtual pointer to a language model // LanguageModelBase* virtual_lm_d; // debug level // // inherited from LanguageModelBase // memory manager // static MemoryManager mgr_d; // format // ALGORITHM format_d; // implementation // IMPLEMENTATION implementation_d; //--------------------------------------------------------------------------- // // required public methods // //--------------------------------------------------------------------------- public: // method: name // static const String& name() { return CLASS_NAME; } // method: diagnose // static bool8 diagnose(Integral::DEBUG debug_level); // debug methods // bool8 debug(const unichar* msg) const { return virtual_lm_d->debug(msg); } // method: setDebug // bool8 setDebug(Integral::DEBUG debug_level) { return (LanguageModelBase::setDebug(debug_level) && virtual_lm_d->setDebug(debug_level)); } // destructor/constructor(s) // // method: destructor // ~LanguageModel() { if (virtual_lm_d != (LanguageModel*)&NO_LANGUAGE_MODEL) { delete virtual_lm_d; } } // method: default constructor // LanguageModel() { implementation_d = DEF_IMPL; format_d = DEF_ALGO; virtual_lm_d = (LanguageModelBase*)&NO_LANGUAGE_MODEL; } // method: copy constructor // LanguageModel(const LanguageModel& arg) { virtual_lm_d = (LanguageModelBase*)&NO_LANGUAGE_MODEL; assign(arg); } // assign methods // bool8 assign(const LanguageModel& arg) { return assign(*arg.virtual_lm_d); } // i/o methods // // method: sofSize // int32 sofSize() const { return (ALGO_MAP.elementSofSize() + IMPL_MAP.elementSofSize() + virtual_lm_d->sofSize()); } // method: read // bool8 read(Sof& sof, int32 tag = DEF_TAG, const String& cname = CLASS_NAME); // method: write // bool8 write(Sof& sof, int32 tag = DEF_TAG, const String& cname = CLASS_NAME) const; // method: readData // bool8 readData(Sof& sof, const String& pname = DEF_PARAM, int32 size = SofParser::FULL_OBJECT, bool8 param = true, bool8 nested = false); // method: writeData // bool8 writeData(Sof& sof, const String& pname = DEF_PARAM) const; // other memory managements methods // bool8 clear(Integral::CMODE cmode = Integral::DEF_CMODE); // equality methods // bool8 eq(const LanguageModel& arg) const { return virtual_lm_d->eq(*arg.virtual_lm_d); } //--------------------------------------------------------------------------- // // class-specific public methods required by interface contract // defined in LanguageModelBase.h // //--------------------------------------------------------------------------- //-------------------------------------------------------- // // other methods // //-------------------------------------------------------- // method: className // const String& className() const { return virtual_lm_d->className(); } // method: getRuleModel // RuleModel getRuleModel() { return virtual_lm_d->getRuleModel(); } // method: setRuleModel // bool8 setRuleModel(const RuleModel& hg) { return virtual_lm_d->setRuleModel(hg); } // method: get // //HierarchicalDigraph& getHDigraph() { // return (HierarchicalDigraph&)0; // } // method: set // //bool8 setHDigraph(const HierarchicalDigraph& hg) { // return false; //} // method: convert // bool8 convert(ALGORITHM format); // method: assign (for LanguageModelBase pointer) // bool8 assign(const LanguageModelBase& arg) { return virtual_lm_d->assign(arg); } // method: eq (for LanguageModelBase pointer) // bool8 eq(const LanguageModelBase& arg) const { return virtual_lm_d->eq(arg); } // method: setFormat // bool8 setFormat(ALGORITHM format); // method: getFormat // ALGORITHM getFormat() { return format_d; } // method: minimizeGraph // bool8 minimizeGraph(); //--------------------------------------------------------------------------- // // private methods // //--------------------------------------------------------------------------- private: }; // end of include file // #endif