00001
00002
00003
00004
00005
00006
00007
00008 #ifndef SEMAINE_DATATYPES_STATEINFO_H
00009 #define SEMAINE_DATATYPES_STATEINFO_H
00010
00011 #include <string>
00012 #include <map>
00013
00014 #include <xercesc/dom/DOM.hpp>
00015
00016 #include <semaine/util/XMLTool.h>
00017
00018 #include <semaine/cms/CMSLogger.h>
00019 #include <semaine/cms/exceptions/SystemConfigurationException.h>
00020 #include <semaine/cms/exceptions/MessageFormatException.h>
00021
00022 #include <semaine/datatypes/stateinfo/XPathInfoMapper.h>
00023
00024 #include <xqilla/xqilla-dom3.hpp>
00025
00026
00027 namespace semaine {
00028
00029 namespace datatypes {
00030
00031 namespace stateinfo {
00032
00033
00034 class StateInfo {
00035 public:
00036
00037 static const std::string APIVersion;
00038 enum Type { AgentState, DialogState, UserState, ContextState, SystemState };
00039 static const Type Types[];
00040 static const int numTypes;
00041 static const std::string TypeNames[];
00042 static const std::map<Type, XPathInfoMapper *> infosByType;
00043
00044 StateInfo(const std::map<std::string, std::string> & infoItems, const std::string & whatState, Type type)
00045 throw(semaine::cms::exceptions::SystemConfigurationException);
00046 virtual ~StateInfo();
00051 Type getType() { return type; }
00059 const std::map<std::string, std::string> & getInfos()
00060 {
00061 return info;
00062 }
00063
00069 bool hasInfo(const std::string & name)
00070 {
00071 return info.find(name) != info.end();
00072 }
00073
00081 const std::string getInfo(const std::string & name)
00082 {
00083 std::map<std::string, std::string>::const_iterator it = info.find(name);
00084 if (it != info.end()) return it->second;
00085 return "";
00086 }
00087
00088 void setInfo(const std::string & name, const std::string & value)
00089 throw(semaine::cms::exceptions::SystemConfigurationException);
00090
00091 XERCES_CPP_NAMESPACE::DOMDocument * getDocument()
00092 throw(semaine::cms::exceptions::SystemConfigurationException);
00093
00094 const std::string & toString()
00095 {
00096 return stateName;
00097 }
00098
00099 const std::string & getAPIVersion()
00100 {
00101 return APIVersion;
00102 }
00103
00104
00105
00106
00107
00108
00109
00110 protected:
00111 std::map<std::string, std::string> info;
00112 XERCES_CPP_NAMESPACE::DOMDocument * doc;
00113 semaine::cms::CMSLogger * log;
00114 const std::string stateName;
00115 Type type;
00116 StateInfo(XERCES_CPP_NAMESPACE::DOMDocument * doc, const std::string & whatState, const std::string & rootName, const std::string & rootNamespace, Type type)
00117 throw(semaine::cms::exceptions::MessageFormatException, semaine::cms::exceptions::SystemConfigurationException);
00118 virtual void createDocumentFromInfo()
00119 throw(semaine::cms::exceptions::SystemConfigurationException);
00120 virtual void analyseDocument(const std::string & rootName, const std::string & rootNamespace)
00121 throw(semaine::cms::exceptions::MessageFormatException, semaine::cms::exceptions::SystemConfigurationException);
00122 };
00123
00124
00125
00126
00127 }
00128
00129 }
00130
00131 }
00132
00133 #endif