diff options
author | fourdan | 2006-05-24 13:02:58 +0000 |
---|---|---|
committer | fourdan | 2006-05-24 13:02:58 +0000 |
commit | e5596cb2311ae3b8ac7d3b9f9f7dbd0e842fde80 (patch) | |
tree | eb5eb30932b0f2dc58fbf8292e82ff88258591e5 /IvyCallback.h | |
parent | 23abb4b87c7e40ed259dd02f653516f60e55ade4 (diff) | |
download | ivy-cplusplus-e5596cb2311ae3b8ac7d3b9f9f7dbd0e842fde80.zip ivy-cplusplus-e5596cb2311ae3b8ac7d3b9f9f7dbd0e842fde80.tar.gz ivy-cplusplus-e5596cb2311ae3b8ac7d3b9f9f7dbd0e842fde80.tar.bz2 ivy-cplusplus-e5596cb2311ae3b8ac7d3b9f9f7dbd0e842fde80.tar.xz |
Initial revision
Diffstat (limited to 'IvyCallback.h')
-rw-r--r-- | IvyCallback.h | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/IvyCallback.h b/IvyCallback.h new file mode 100644 index 0000000..1d47dc4 --- /dev/null +++ b/IvyCallback.h @@ -0,0 +1,132 @@ +// IvyCallback.h : Interface for the IvyMessageCallback Class +// : Interface for the IvyDirectMessageCallback Class +// : Interface for the IvyApplicationCallback Class +// + + +#ifndef __IVYXTLOOP_H__ +#define __IVYXTLOOP_H__ + +class IvyApplication; + +/* Callback for the normal bus Message */ + +class IvyMessageCallback { +public: + virtual void OnMessage (IvyApplication *app, int argc, const char **argv )=0; + virtual ~IvyMessageCallback() + { + } +}; + + +class IvyMessageCallbackFunction: public IvyMessageCallback { +public: + typedef void ( *IvyMessageCallback_fun )( IvyApplication *app, void *user_data, int argc, const char **argv ); + IvyMessageCallback_fun MessageCb; + void *data; + +public: + IvyMessageCallbackFunction ( IvyMessageCallback_fun m_cb, void *udata = NULL ) : MessageCb( m_cb ) + { + data = udata; + } + ~IvyMessageCallbackFunction () + { + } + void OnMessage (IvyApplication *app, int argc, const char **argv) + { + (*MessageCb) (app, data, argc, argv); + } + +/* raccourci d'ecriture */ +#define BUS_CALLBACK( m , d ) new IvyMessageCallbackFunction( m, d ) +}; +/* template Class Callback for the normal bus Message */ +template <class T> class IvyMessageCallbackOf : public IvyMessageCallback { + +protected: + T* Object; + typedef void ( T::*IvyMessageCallback_fun )( IvyApplication *app, int argc, const char **argv ); + IvyMessageCallback_fun MessageCb; + +public: + IvyMessageCallbackOf ( T* o, IvyMessageCallback_fun m_cb ) : Object (o), MessageCb( m_cb ) + { + } + ~IvyMessageCallbackOf () + { + } + void OnMessage (IvyApplication *app, int argc, const char **argv) + { + (Object->*MessageCb) (app, argc, argv); + } + +/* raccourci d'ecriture */ +#define BUS_CALLBACK_OF( cl, m ) new IvyMessageCallbackOf<cl>( this, m ) +}; +/* Callback for the direct Message */ +class IvyDirectMessageCallback { +public: + virtual void OnDirectMessage (IvyApplication *app, int id, const char *arg ) = 0; + virtual ~IvyDirectMessageCallback () {}; +}; + +/* Application Callback */ + +class IvyApplicationCallback { +public: + virtual void OnApplicationConnected (IvyApplication *app) = 0; + virtual void OnApplicationDisconnected (IvyApplication *app) = 0; + virtual ~IvyApplicationCallback() + { + } +}; +class IvyApplicationNullCallback : public IvyApplicationCallback { +public: + virtual void OnApplicationConnected (IvyApplication *app) + {}; + virtual void OnApplicationDisconnected (IvyApplication *app) + {}; + virtual ~IvyApplicationNullCallback() + { + } +}; + +// Static function CB +class IvyApplicationCallbackFunction: public IvyApplicationCallback { +public: + typedef void ( *IvyApplicationCallback_fun )( IvyApplication *app ); + IvyApplicationCallback_fun ApplicationConnectedCb; + IvyApplicationCallback_fun ApplicationDisconnectedCb; + +public: + IvyApplicationCallbackFunction ( IvyApplicationCallback_fun con_cb, IvyApplicationCallback_fun disc_cb) + : ApplicationConnectedCb( con_cb ), ApplicationDisconnectedCb( disc_cb ) + { + } + ~IvyApplicationCallbackFunction () + { + } + virtual void OnApplicationConnected (IvyApplication *app) + { + (*ApplicationConnectedCb) (app); + }; + virtual void OnApplicationDisconnected (IvyApplication *app) + { + (*ApplicationDisconnectedCb) (app); + }; + +/* raccourci d'ecriture */ +#define BUS_APPLICATION_CALLBACK( conn, disconn ) new IvyApplicationCallbackFunction( conn, disconn ) +}; +/* Callback for the die Message */ +class IvyDieCallback { +public: + virtual bool OnDie (IvyApplication *app, int id, const char *arg ) = 0; + virtual ~IvyDieCallback() + { + } +}; +#endif // __IVYXTLOOP_H__ + |