00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __CODEX_KEYSERVICE_SUPPORTEDCLIENTRESPONSEEVENT_H__
00022 #define __CODEX_KEYSERVICE_SUPPORTEDCLIENTRESPONSEEVENT_H__
00023
00024 #include "CODEX_Events/Event.h"
00025 #include "SupportedClientResponse.h"
00026 #include "CODEX_Server/RoutingInfo.h"
00027
00028 namespace CODEX_KeyService
00029 {
00030 class SupportedClientResponseHandler;
00031
00040 class SupportedClientResponseEventBase : public CODEX_Events::EventBase,
00041 public CODEX_Server::RoutingInfo
00042 {
00043 public :
00048 SupportedClientResponseEventBase( CODEX_Events::Activity* source,
00049 unsigned char* server,
00050 unsigned char* seqNum ) :
00051 CODEX_Events::EventBase( source ),
00052 RoutingInfo( server, seqNum )
00053 {}
00054
00056 virtual ~SupportedClientResponseEventBase() {}
00057
00059 virtual int marshal( unsigned char ** pp ) = 0;
00060
00062 virtual bool unmarshal( unsigned char ** pp, long length ) = 0;
00063 };
00064
00071 template< class RespT , class ReqT >
00072 class SupportedClientResponseEvent : public SupportedClientResponseEventBase
00073 {
00074 public :
00076 typedef SupportedClientResponse< RespT , ReqT > MsgType;
00077
00079 SupportedClientResponseEvent(
00080 CODEX_Events::Activity* source,
00081 unsigned char* server,
00082 unsigned char* seqNum,
00083 SupportedClientResponseHandler* destination,
00084 const MsgType& message ) :
00085 SupportedClientResponseEventBase( source, server, seqNum ),
00086 m_destination( destination ),
00087 m_message( message )
00088 {}
00089
00091 SupportedClientResponseEvent(
00092 CODEX_Events::Activity* source,
00093 unsigned char* server,
00094 unsigned char* seqNum,
00095 SupportedClientResponseHandler* destination ) :
00096 SupportedClientResponseEventBase( source, server, seqNum ),
00097 m_destination( destination )
00098 {}
00099
00101 virtual ~SupportedClientResponseEvent() {}
00102
00104 const MsgType& message() const { return m_message; }
00105
00110 bool handle() { return m_destination->handler( *this ); }
00111
00119 void reRoute( SupportedClientResponseHandler* newDestination )
00120 {
00121 m_destination = newDestination;
00122 }
00123
00125 int marshal( unsigned char ** pp )
00126 {
00127 return m_message.marshal(pp);
00128 }
00129
00131 bool unmarshal( unsigned char ** pp, long length )
00132 {
00133 if ( NULL == m_message.unmarshal( NULL, pp, length ) )
00134 {
00135 return false;
00136 }
00137 return true;
00138 }
00139
00140 private :
00141 SupportedClientResponseHandler* m_destination;
00142 MsgType m_message;
00143 };
00144 }
00145
00146 #endif