Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   Related Pages  

SupportedClientResponseEvent.h

00001 /*
00002  * Copyright 2003 Michael A. Marsh, Cornell University. All rights reserved.
00003  * This software is released under the modified BSD license.
00004  * See the file LICENSE in the top-level directory for details.
00005  */
00006 //
00007 // $Id: SupportedClientResponseEvent.h,v 1.3 2004/05/19 15:56:53 mmarsh Exp $
00008 //
00009 // $Log: SupportedClientResponseEvent.h,v $
00010 // Revision 1.3  2004/05/19 15:56:53  mmarsh
00011 // *** empty log message ***
00012 //
00013 // Revision 1.2  2003/11/04 22:31:49  mmarsh
00014 // *** empty log message ***
00015 //
00016 //
00017 
00018 #ifndef __CODEX_KEYSERVICE_SUPPORTEDCLIENTRESPONSEEVENT_H__
00019 #define __CODEX_KEYSERVICE_SUPPORTEDCLIENTRESPONSEEVENT_H__
00020 
00021 #include "CODEX_Events/Event.h"
00022 #include "SupportedClientResponse.h"
00023 #include "CODEX_Server/RoutingInfo.h"
00024 
00025 namespace CODEX_KeyService
00026 {
00027    class SupportedClientResponseHandler;
00028 
00037    class SupportedClientResponseEventBase : public CODEX_Events::EventBase,
00038                                             public CODEX_Server::RoutingInfo
00039    {
00040       public :
00045          SupportedClientResponseEventBase( CODEX_Events::Activity* source,
00046                                            unsigned char* server,
00047                                            unsigned char* seqNum ) :
00048             CODEX_Events::EventBase( source ),
00049             RoutingInfo( server, seqNum )
00050          {}
00051 
00053          virtual ~SupportedClientResponseEventBase() {}
00054 
00056          virtual int marshal( unsigned char ** pp ) = 0;
00057 
00059          virtual bool unmarshal( unsigned char ** pp, long length ) = 0;
00060    };
00061 
00068    template< class RespT , class ReqT >
00069    class SupportedClientResponseEvent : public SupportedClientResponseEventBase
00070    {
00071       public :
00073          typedef SupportedClientResponse< RespT , ReqT > MsgType;
00074 
00076          SupportedClientResponseEvent(
00077             CODEX_Events::Activity* source,
00078             unsigned char* server,
00079             unsigned char* seqNum,
00080             SupportedClientResponseHandler* destination,
00081             const MsgType& message ) :
00082             SupportedClientResponseEventBase( source, server, seqNum ),
00083             m_destination( destination ),
00084             m_message( message )
00085          {}
00086 
00088          SupportedClientResponseEvent(
00089             CODEX_Events::Activity* source,
00090             unsigned char* server,
00091             unsigned char* seqNum,
00092             SupportedClientResponseHandler* destination ) :
00093             SupportedClientResponseEventBase( source, server, seqNum ),
00094             m_destination( destination )
00095          {}
00096 
00098          virtual ~SupportedClientResponseEvent() {}
00099 
00101          const MsgType& message() const { return m_message; }
00102 
00107          bool handle() { return m_destination->handler( *this ); }
00108 
00116          void reRoute( SupportedClientResponseHandler* newDestination )
00117          {
00118             m_destination = newDestination;
00119          }
00120 
00122          int marshal( unsigned char ** pp )
00123          {
00124             return m_message.marshal(pp);
00125          }
00126 
00128          bool unmarshal( unsigned char ** pp, long length )
00129          {
00130             if ( NULL == m_message.unmarshal( NULL, pp, length ) )
00131             {
00132                return false;
00133             }
00134             return true;
00135          }
00136 
00137       private :
00138          SupportedClientResponseHandler*  m_destination;
00139          MsgType                          m_message;
00140    };
00141 }
00142 
00143 #endif /* __CODEX_KEYSERVICE_SUPPORTEDCLIENTRESPONSEEVENT_H__ */

Generated on Wed Jun 2 16:32:56 2004 for COrnell Data EXchange (CODEX) by doxygen1.2.18