From 8538e20f9ef0bb69a6b7a82f8b46e662d59ce398 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 12:56:04 +0000 Subject: Utilisateur : Fcolin Date : 6/01/03 Heure : 14:47 Archivé dans $/Bus/Ivy Commentaire: (vss 14) --- Ivy/Ivy.cxx | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'Ivy') diff --git a/Ivy/Ivy.cxx b/Ivy/Ivy.cxx index e5b11ea..8b26e77 100644 --- a/Ivy/Ivy.cxx +++ b/Ivy/Ivy.cxx @@ -27,6 +27,7 @@ Ivy::~Ivy() // remove all app and stop watcher stop(); regexp_out.clear(); + if ( synchronous ) { @@ -55,7 +56,7 @@ Ivy::~Ivy() Ivy::Ivy(const char* name, const char * ready, IvyApplicationCallback *callback, bool Synchronous) { InitializeCriticalSection( &m_application_cs ); - + regexp_id = 0; synchronous = Synchronous; if ( synchronous ) IvySynchronousCallback::m_synchro = new IvySynchroWnd(); @@ -129,7 +130,6 @@ void Ivy::stop() } int Ivy::BindMsg(const char *regexp, IvyMessageCallback *cb) { - static int id = 0; regexp_out.push_back( regexp ); callbacks.push_back( synchronous ? new IvySynchronousMessageCallback(cb) : cb ); @@ -138,11 +138,32 @@ int Ivy::BindMsg(const char *regexp, IvyMessageCallback *cb) for ( iter = applications.begin() ; iter != applications.end() ; ++iter ) { IvyApplication *app = *iter; - app->SendMsg(IvyApplication::AddRegexp, id, regexp ); + app->SendMsg(IvyApplication::AddRegexp, regexp_id, regexp ); } - return id++; + return regexp_id++; } +int Ivy::BindMsg( IvyMessageCallback *cb, const char *regexp, ... ) +{ + char buffer[4096]; + va_list args; + + va_start( args, regexp ); /* Initialize variable arguments. */ + vsprintf( buffer, regexp, args ); + va_end( args); + + regexp_out.push_back( regexp ); + callbacks.push_back( synchronous ? new IvySynchronousMessageCallback(cb) : cb ); + /* send to already connected */ + IvyApplicationList::iterator iter; + for ( iter = applications.begin() ; iter != applications.end() ; ++iter ) + { + IvyApplication *app = *iter; + app->SendMsg(IvyApplication::AddRegexp, regexp_id, buffer ); + } + return regexp_id++; +} + void Ivy::UnbindMsg(int id) { regexp_out[ id ] = ""; -- cgit v1.1