From c015cda281027bf04d8bfa2ec4e44b7f594c4379 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 13:01:29 +0000 Subject: Utilisateur : Fcolin Date : 1/06/06 Heure : 10:14 Archivé dans $/Bus/Ivy Commentaire: ajout Binding Callback et SetFilter (vss 10) --- Bus/Ivy/IvyCallback.h | 61 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) (limited to 'Bus/Ivy') diff --git a/Bus/Ivy/IvyCallback.h b/Bus/Ivy/IvyCallback.h index 78aff80..ede0ef4 100644 --- a/Bus/Ivy/IvyCallback.h +++ b/Bus/Ivy/IvyCallback.h @@ -103,16 +103,73 @@ public: } virtual void OnApplicationConnected (IvyApplication *app) { - (*ApplicationConnectedCb) (app); + if ( ApplicationConnectedCb ) (*ApplicationConnectedCb) (app); }; virtual void OnApplicationDisconnected (IvyApplication *app) { - (*ApplicationDisconnectedCb) (app); + if ( ApplicationDisconnectedCb ) (*ApplicationDisconnectedCb) (app); }; /* raccourci d'ecriture */ #define BUS_APPLICATION_CALLBACK( conn, disconn ) new IvyApplicationCallbackFunction( conn, disconn ) }; + +/* Binding Callback */ + +class IvyBindingCallback { +public: + virtual void OnAddBind (IvyApplication *app, int id, const char * regexp) = 0; + virtual void OnRemoveBind (IvyApplication *app, int id, const char * regexp) = 0; + virtual void OnFilterBind (IvyApplication *app, int id, const char * regexp) = 0; + virtual ~IvyBindingCallback() + { + } +}; +class IvyBindingNullCallback : public IvyBindingCallback { +public: + virtual void OnAddBind (IvyApplication *app, int id, const char * regexp) + {}; + virtual void OnRemoveBind (IvyApplication *app, int id, const char * regexp) + {}; + virtual void OnFilterBind (IvyApplication *app, int id, const char * regexp) + {}; + virtual ~IvyBindingNullCallback() + { + } +}; +// Static function CB +class IvyBindingCallbackFunction: public IvyBindingCallback { +public: + typedef void ( *IvyBindingCallback_fun )( IvyApplication *app, int id, const char * regexp ); + IvyBindingCallback_fun BindingAddCb; + IvyBindingCallback_fun BindingRemoveCb; + IvyBindingCallback_fun BindingFilterCb; + +public: + IvyBindingCallbackFunction ( IvyBindingCallback_fun add_cb, IvyBindingCallback_fun remove_cb, IvyBindingCallback_fun filter_cb ) + : BindingAddCb( add_cb ), BindingRemoveCb( remove_cb ), BindingFilterCb( filter_cb ) + { + } + ~IvyBindingCallbackFunction () + { + } + virtual void OnAddBind (IvyApplication *app, int id, const char * regexp) + { + if(BindingAddCb) (*BindingAddCb) (app, id, regexp); + }; + virtual void OnRemoveBind (IvyApplication *app, int id, const char * regexp) + { + if (BindingRemoveCb) (*BindingRemoveCb) (app, id, regexp); + }; + virtual void OnFilterBind (IvyApplication *app, int id, const char * regexp) + { + if(BindingFilterCb ) (*BindingFilterCb) (app, id, regexp); + }; + +/* raccourci d'ecriture */ +#define BUS_BINDING_CALLBACK( add, remove, filter ) new IvyBindingCallbackFunction( add, remove, filter ) +}; + /* Callback for the die Message */ class IvyDieCallback { public: -- cgit v1.1