Message.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00032
00033
00034 #ifndef __MESSAGE_INCLUDED_
00035 #define __MESSAGE_INCLUDED_
00036
00037 #ifdef MIP_HOST_APPLE
00038 #include <applePatch.h>
00039 #endif
00040
00041
00042 #include <stdio.h>
00043 #include <string.h>
00044
00045 #include <iostream>
00046
00047
00048 namespace MipBaselib{
00049
00050 using namespace std;
00051
00055
00057
00058
00062 class Message{
00063 private:
00064 char _id[8];
00065
00066 protected:
00067 Message(){
00068 memset(_id,0,8);
00069 }
00070
00071 template <class Class> void constructor(const string& inMessage) {
00072 inMessage.copy((char* ) this, sizeof(Class));
00073 }
00074
00075 template <class Class> void encoder(string& outMessage){
00076 outMessage = string((char* ) this, sizeof(Class));
00077 }
00078
00079
00080 public:
00082 Message(const string& inMessage);
00083
00085 void setId(string& inId);
00086
00088 bool checkId(string inId);
00089 };
00090
00094 class MessageHandler{
00095
00096 protected:
00097
00098 public:
00099 MessageHandler(){};
00100
00101 virtual void handleMessage(string encodedMsg,string address)=0;
00102 };
00103
00104
00105
00106
00107 };
00108
00109
00110 #endif
00111
00112
00113
00114
00115
00116