// file: $isip/class/pr/ProductionRule/ProductionRule.h // version: $Id: ProductionRule.h 10497 2006-03-15 21:40:16Z may $ #ifndef ISIP_PRODUCTIONRULE #define ISIP_PRODUCTIONRULE //--------------------------------------------------------------------------- // // ISIP include files // //--------------------------------------------------------------------------- #ifndef ISIP_STRING #include #endif #ifndef ISIP_DOUBLE_LINKED_LIST #include #endif #ifndef ISIP_PRODUCTIONRULETOKENTYPE #include #endif #ifndef ISIP_FLOAT #include #endif #ifndef ISIP_FILENAME #include #endif #ifndef ISIP_FILE #include #endif #ifndef ISIP_DEBUGLEVEL #include #endif #ifndef ISIP_TRIPLE #include #endif #ifndef ISIP_SOF #include #endif class ProductionRule { public: //--------------------------------------------------------------------------- // // public constants // //--------------------------------------------------------------------------- public: // constant: class name // static const String CLASS_NAME; //--------------------------------------- // // type related constants // //--------------------------------------- // enum TYPE {NORMAL=0, START, DEF_TYPE = NORMAL}; // define type NameMap object // static const NameMap TYPE_MAP; //--------------------------------------- // // file i/o constants // //--------------------------------------- // static const String DEF_PARAM; static const String PARAM_RULE_NAME; static const String PARAM_RULE_TYPE; static const String PARAM_RULE; static const String RULE_NAME_BASE; static const String START_RULE_NAME; static const String TERM_RULE_NAME; static const String DEF_RULE_NAME; static const int32 DEF_TAG; //--------------------------------------- // // error codes // //--------------------------------------- // //--------------------------------------------------------------------------- // // protected data // //--------------------------------------------------------------------------- protected: // rule name // String rule_name_d; // rule type // TYPE rule_type_d; // rule list. this contains a series of operators and tokens and weights // DoubleLinkedList< Triple > rule_d; // debug level // DebugLevel debug_level_d; //--------------------------------------------------------------------------- // // required public methods // //--------------------------------------------------------------------------- public: // method: name // static const String& name() { return CLASS_NAME; } // method: diagnose // static bool8 diagnose(Integral::DEBUG level); // method: debug // bool8 debug(const unichar* msg) const; // constructor // ProductionRule (); // method: read // bool8 read(Sof& sof, int32 tag, const String& cname = CLASS_NAME); // method: readData // bool8 readData(Sof& sof, const String& pname = DEF_PARAM, int32 size = SofParser::FULL_OBJECT, bool8 param = true, bool8 nested = false); // method: write // bool8 write(Sof& sof, int32 tag, const String& cname = CLASS_NAME) const; // method: writeData // bool8 writeData(Sof& sof, const String& pname = DEF_PARAM) const; // method: sofSize // int32 sofSize() const { return rule_d.sofSize()+rule_name_d.sofSize(); } // method: assign // bool8 assign(const ProductionRule& prdrl_a); // method: operator= // bool8 operator=(const ProductionRule& prdrl_a); // method: eq // bool8 eq(const ProductionRule& prdrl_a) const; // method: operator== // bool8 operator==(const ProductionRule& prdrl_a) const; // method: clear // bool8 clear(Integral::CMODE ctype = Integral::DEF_CMODE); //--------------------------------------------------------------------------- // // class-specific public methods // //--------------------------------------------------------------------------- public: int32 length() const; //---------------------------------------------------------- // // traversal methods and traversal-based operations // //---------------------------------------------------------- // method: removeCurr() // bool8 removeCurr(); // method: gotoFirst // bool8 gotoFirst(); // method: gotoNext // bool8 gotoNext(); // method: gotoPrev // bool8 gotoPrev(); // method: gotoPosition // bool8 gotoPosition(int32 position); // method: getType // bool8 setType(ProductionRuleTokenType type); // method: getValue // bool8 setValue(String value); // method: getWeight // bool8 setWeight(Float weight); // method: getType // ProductionRuleTokenType::TYPE getType(); // method: getValue // String getValue(); // method: getWeight // Float getWeight(); // method: insert // bool8 insert(const ProductionRuleTokenType::TYPE& type_a, const String& value_a=L"", Float weight_a=0); // method: append // bool8 append(const ProductionRuleTokenType::TYPE& type_a, const String& value_a, Float weight_a); bool8 append(const ProductionRuleTokenType::TYPE& type_a, const String& value_a=L""); //---------------------------------------------------------- // // get methods // //---------------------------------------------------------- // get rule - return a string representation of the entire rule // String getRule(); // get rule name // String getRuleName(); // method: getRuleType // TYPE getRuleType() { return rule_type_d; } //---------------------------------------------------------- // // set methods // //---------------------------------------------------------- // set rule name // bool8 setRuleName(const String& rule_name_a); // method: setDebug // bool8 setDebug(Integral::DEBUG level) { debug_level_d = level; return true; } // method: setRuleType // bool8 setRuleType(TYPE type_a) { rule_type_d = type_a; return true; } //--------------------------------------------------------------------------- // // class-specific protected methods // //--------------------------------------------------------------------------- protected: // method: convertToString // String convertToString(Triple& item_a); }; #endif