//// Name: msgdata.h //// Purpose: Header for class MsgData. //// Author: Youchen Lee ( utcr.org ) //// Licence: GPL : http://www.gnu.org/licenses/gpl.html #ifndef __INCLUDE_MSGDATA_H__ #define __INCLUDE_MSGDATA_H__ #include #include #include #include #include #include #include using namespace std; // BOT_RUN_LEVEL #define USE_BASE (unsigned char) 001 #define USE_UNKNOW (unsigned char) 002 #define USE_ANGRY (unsigned char) 004 #define USE_LOG (unsigned char) 010 #define USE_AUTO_LEARN (unsigned char) 020 #define USE_TEACH (unsigned char) 040 #define USE_USER_DEFINED_USAGES (unsigned char) 0100 class MsgData { private: // functions int initFilename(); int initSpecialMsg(string); int initCommonMsg(); int initUnknowMsgToAsk(); int initUserDefinedUsages(); int writeToMsgData(); bool writeUnknowLog(); int errorHandler(int, const string &); int errorHandler(int, const string &, const string &); // STL vector V_MsgAngry; vector V_MsgUnknow; vector V_MsgAsk; typedef map > VS_map; map MT; // map table VS_map VSM_MsgLearnToSave; VS_map VSM_UserDefinedUsages; map M_MsgUnknowToAsk; // vars string BOT_NAME; string CONFIG_PATH; string filename_conf; string filename_common_msg; string filename_unknow_log; string filename_user_defined_usages; unsigned char BOT_RUN_LEVEL; unsigned int LEVEL__ADD_TO_UNKNOW_MSG; // unsigned int LEVEL__ASK_UNKNOW_MSG; unsigned int LEVEL__RE_LEARNING; bool learn_something; public: MsgData(string bot_name = "default", string config_path = "./", unsigned char old_level = 0177, int level__re_learning = 5, int level__add_to_unknow_msg = 10 ); ~MsgData(); int ref_counter; int getSpecialMsg(int status, string &); int getCommonMsg(string &, string &, bool); int learning(string &, string &); bool getUnknowMsgToAsk(string &); bool getUserDefinedUsages(string &key,string &query, string &msg); int addUnknowMsgToAsk(string &); int addOldMsgToAskAgain(string); unsigned char getBotRunLevel(); bool setLevel__ReLearning(int num) { if( num >= 0 ) { LEVEL__RE_LEARNING = num; return true; } else return false; } bool setLevel__AddToUnknowMsg(int num) { if( num >= 0 ) { LEVEL__ADD_TO_UNKNOW_MSG = num; return true; } else return false; } }; #endif