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

ClientResponseEvent.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: ClientResponseEvent.h,v 1.3 2004/05/19 15:56:51 mmarsh Exp $
00008 //
00009 // $Log: ClientResponseEvent.h,v $
00010 // Revision 1.3  2004/05/19 15:56:51  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_CLIENT_RESPONSE_EVENT_H__
00019 #define __CODEX_KEYSERVICE_CLIENT_RESPONSE_EVENT_H__
00020 
00021 #include "CODEX_Events/Event.h"
00022 //#include "CODEX_Client/Message.h"
00023 
00024 namespace CODEX_KeyService
00025 {
00026    class ClientResponseHandler;
00027 
00034    class ClientResponseEventBase : public CODEX_Events::EventBase
00035    {
00036       public :
00041          ClientResponseEventBase( CODEX_Events::Activity* source ) :
00042             CODEX_Events::EventBase( source )
00043          {}
00044 
00046          virtual ~ClientResponseEventBase() {}
00047 
00049          virtual int marshal( unsigned char ** pp ) = 0;
00050    };
00051 
00058    template< class MT >
00059    class ClientResponseEvent : public ClientResponseEventBase
00060    {
00061       public :
00063          ClientResponseEvent( CODEX_Events::Activity* source,
00064                               ClientResponseHandler* destination,
00065                               const MT& message,
00066                               bool acknowledge=false ) :
00067             ClientResponseEventBase( source ),
00068             m_destination( destination ),
00069             m_message( message ),
00070             m_acknowledge( acknowledge )
00071          {}
00072 
00074          virtual ~ClientResponseEvent() {}
00075 
00077          const MT& message() const { return m_message; }
00078 
00080          bool acknowledge() const { return m_acknowledge; }
00081 
00086          bool handle() { return m_destination->handler( *this ); }
00087 
00095          void reRoute( ClientResponseHandler* newDestination )
00096          {
00097             m_destination = newDestination;
00098          }
00099 
00101          int marshal( unsigned char ** pp )
00102          {
00103             return m_message.marshal(pp);
00104          }
00105 
00106       private :
00107          ClientResponseHandler*  m_destination;
00108          MT                      m_message;
00109          bool                    m_acknowledge;
00110    };
00111 }
00112 
00113 #endif /* __CODEX_KEYSERVICE_CLIENT_RESPONSE_EVENT_H__ */

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