Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File 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.4 2005/01/21 19:44:17 mmarsh Exp $
00008 //
00009 // $Log: SupportedClientResponseEvent.h,v $
00010 // Revision 1.4  2005/01/21 19:44:17  mmarsh
00011 // Updated for compatibility with Doxygen 1.4.1
00012 //
00013 // Revision 1.3  2004/05/19 15:56:53  mmarsh
00014 // *** empty log message ***
00015 //
00016 // Revision 1.2  2003/11/04 22:31:49  mmarsh
00017 // *** empty log message ***
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 /* __CODEX_KEYSERVICE_SUPPORTEDCLIENTRESPONSEEVENT_H__ */

Generated on Fri May 6 17:41:27 2005 for COrnell Data EXchange (CODEX) by  doxygen 1.4.1