Response.h

00001 #ifndef ERIS_RESPONSE_H
00002 #define ERIS_RESPONSE_H
00003 
00004 #include <Atlas/Objects/ObjectsFwd.h>
00005 #include <map>
00006 
00007 namespace Eris
00008 {
00009 
00010 class ResponseBase
00011 {
00012 public:
00013     virtual ~ResponseBase();
00014     
00019     virtual bool responseReceived(const Atlas::Objects::Operation::RootOperation& op) = 0;
00020 };
00021 
00022 class NullResponse : public ResponseBase
00023 {
00024 public:
00025     virtual bool responseReceived(const Atlas::Objects::Operation::RootOperation&);
00026 };
00027 
00028 template <class T>
00029 class MemberResponse : public ResponseBase
00030 {
00031 public:
00032    typedef void (T::*T_method)(const Atlas::Objects::Operation::RootOperation& op);
00033 
00034     MemberResponse(T *obj, void (T::*method)(const Atlas::Objects::Operation::RootOperation& op)) :
00035                 m_object(obj),
00036                 m_func(method)
00037         {
00038         }
00039         
00040         virtual bool responseReceived(const Atlas::Objects::Operation::RootOperation& op)
00041         {
00042                 (m_object->*m_func)(op);
00043         return true;
00044         }
00045 
00046 private:
00047     T* m_object;
00048     T_method m_func;
00049 };
00050 
00051 class ResponseTracker
00052 {
00053 public:
00054     void await(int serialno, ResponseBase*);
00055     
00056     template <class T>
00057     void await(int serial, T* ins, void (T::*method)(const Atlas::Objects::Operation::RootOperation& op) )
00058     {
00059         await(serial, new MemberResponse<T>(ins, method));
00060     }
00061     
00062     void ignore(int serial)
00063     {
00064         await(serial, new NullResponse());
00065     }
00066     
00067     bool handleOp(const Atlas::Objects::Operation::RootOperation& op);
00068 
00069 private:
00070     typedef std::map<int, ResponseBase*> RefnoResponseMap;
00071     RefnoResponseMap m_pending;
00072 };
00073 
00074 } // of namespace
00075 
00076 #endif // of ERIS_RESPONSE_H

Generated on Tue Feb 7 13:20:24 2006 for Eris by  doxygen 1.4.6