00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef OTMESSAGE_H
00013 #define OTMESSAGE_H
00014
00015 #include "ot_lib.h"
00016
00017
00018
00019 typedef enum {ACTION,
00020 ACTIONRESP,
00021 GET,
00022 GETRESP,
00023 SET,
00024 SETRESP,
00025 PING,
00026 PINGRESP,
00027 DUMP,
00028 DUMPRESP,
00029 ERROR
00030 } OT_MESSAGE_TYPE;
00031
00032
00033
00034 class ot_messageBase
00035 {
00036 protected:
00037
00038 OT_MESSAGE_TYPE m_type;
00039
00040 ot_messageBase(OT_MESSAGE_TYPE type) : m_type(type) {}
00041
00042
00043 public:
00044
00045 virtual ~ot_messageBase(void) {}
00046
00047 OT_MESSAGE_TYPE getType(void) const {return(m_type);}
00048
00049 static ot_messageBase * decodeMessage(const ot_map &input);
00050
00051 virtual const string getMessageCode(void) const = 0;
00052
00053 virtual void encode(ot_map &msg) const = 0;
00054
00055 virtual void makeHeader(ot_map &msg) const = 0;
00056 };
00057
00058
00059 class ot_messageResponse;
00060 class ot_functionManager;
00061
00062
00063 class ot_messageRequest : public ot_messageBase
00064 {
00065 private:
00066
00067 protected:
00068
00069 ot_messageRequest(OT_MESSAGE_TYPE type) : ot_messageBase(type) {}
00070
00071
00072 public:
00073
00074 void makeHeader(ot_map &msg) const;
00075
00076 virtual auto_ptr<ot_messageResponse> exec(ot_functionManager &fm) = 0;
00077 };
00078
00079
00080 class ot_messageResponse : public ot_messageBase
00081 {
00082 private:
00083
00084 protected:
00085
00086 ot_messageResponse(OT_MESSAGE_TYPE type) : ot_messageBase(type) {}
00087
00088
00089 public:
00090
00091 void makeHeader(ot_map &msg) const;
00092 };
00093
00094 #endif