summaryrefslogtreecommitdiff
path: root/Ivy/IvyCallback.h
diff options
context:
space:
mode:
authorfcolin2007-02-01 13:29:31 +0000
committerfcolin2007-02-01 13:29:31 +0000
commitafe2e7dfc1388cad991e8d38dda7d648c137aa52 (patch)
tree92bf63d2b2b34a805927aa294c7c51912638f66a /Ivy/IvyCallback.h
parent0be65f8a110ee9bf5da9c93e0bd5b5b62b3bad0c (diff)
parent04c263c314499e38d64af9d4a1aa5e2b8d9d5ead (diff)
downloadivy-cplusplus-afe2e7dfc1388cad991e8d38dda7d648c137aa52.zip
ivy-cplusplus-afe2e7dfc1388cad991e8d38dda7d648c137aa52.tar.gz
ivy-cplusplus-afe2e7dfc1388cad991e8d38dda7d648c137aa52.tar.bz2
ivy-cplusplus-afe2e7dfc1388cad991e8d38dda7d648c137aa52.tar.xz
modif struct svnwindows@3001
Diffstat (limited to 'Ivy/IvyCallback.h')
-rw-r--r--Ivy/IvyCallback.h180
1 files changed, 180 insertions, 0 deletions
diff --git a/Ivy/IvyCallback.h b/Ivy/IvyCallback.h
new file mode 100644
index 0000000..ede0ef4
--- /dev/null
+++ b/Ivy/IvyCallback.h
@@ -0,0 +1,180 @@
+// IvyCallback.h : Interface for the IvyMessageCallback Class
+// : Interface for the IvyDirectMessageCallback Class
+// : Interface for the IvyApplicationCallback Class
+//
+
+
+#pragma once
+
+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, &cl::m )
+};
+/* Callback for the direct Message */
+class IvyDirectMessageCallback {
+public:
+ virtual void OnDirectMessage (IvyApplication *app, int id, const char *arg ) = 0;
+};
+
+/* 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)
+ {
+ if ( ApplicationConnectedCb ) (*ApplicationConnectedCb) (app);
+ };
+ virtual void OnApplicationDisconnected (IvyApplication *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:
+ virtual bool OnDie (IvyApplication *app, int id, const char *arg ) = 0;
+ virtual ~IvyDieCallback()
+ {
+ }
+};