summaryrefslogtreecommitdiff
path: root/Ivy/Ivy.cxx
diff options
context:
space:
mode:
authorfcolin2007-02-01 12:55:42 +0000
committerfcolin2007-02-01 12:55:42 +0000
commit04c9642429d5008dd5cb6a90ca7fa544c20d6fc8 (patch)
tree6a33049be754aafbbed07810b9e3a863cd3a57e2 /Ivy/Ivy.cxx
parent574e115b9a6ee3e2469084a874bfa04f18316208 (diff)
downloadivy-cplusplus-04c9642429d5008dd5cb6a90ca7fa544c20d6fc8.zip
ivy-cplusplus-04c9642429d5008dd5cb6a90ca7fa544c20d6fc8.tar.gz
ivy-cplusplus-04c9642429d5008dd5cb6a90ca7fa544c20d6fc8.tar.bz2
ivy-cplusplus-04c9642429d5008dd5cb6a90ca7fa544c20d6fc8.tar.xz
Utilisateur : Fcolin Date : 20/07/00 Heure : 10:57 Archivé dans $/Ivy (vss 3)
Diffstat (limited to 'Ivy/Ivy.cxx')
-rw-r--r--Ivy/Ivy.cxx41
1 files changed, 21 insertions, 20 deletions
diff --git a/Ivy/Ivy.cxx b/Ivy/Ivy.cxx
index fd762b6..9091264 100644
--- a/Ivy/Ivy.cxx
+++ b/Ivy/Ivy.cxx
@@ -112,9 +112,10 @@ void Ivy::stop()
{
watcher->stop();
- for ( int pos = 0 ; pos < applications.size() ; pos++ )
+ IvyApplicationList::iterator iter;
+ for ( iter = applications.begin() ; iter != applications.end() ; ++iter )
{
- IvyApplication *app = applications[pos];
+ IvyApplication *app = *iter;
delete app;
}
applications.clear();
@@ -126,9 +127,10 @@ int Ivy::BindMsg(const char *regexp, IvyMessageCallback *cb)
callbacks.push_back( synchronous ? new IvySynchronousMessageCallback(cb) : cb );
/* send to already connected */
- for ( int pos = 0 ; pos < applications.size() ; pos ++ )
+ IvyApplicationList::iterator iter;
+ for ( iter = applications.begin() ; iter != applications.end() ; ++iter )
{
- IvyApplication *app = applications[ pos ];
+ IvyApplication *app = *iter;
app->SendMsg(IvyApplication::AddRegexp, id, regexp );
}
return id++;
@@ -139,9 +141,10 @@ void Ivy::UnbindMsg(int id)
regexp_out[ id ] = "";
callbacks[ id ] = NULL;
/* send to already connected */
- for ( int pos = 0 ; pos < applications.size(); pos ++ )
+ IvyApplicationList::iterator iter;
+ for ( iter = applications.begin() ; iter != applications.end() ; ++iter )
{
- IvyApplication *app = applications[ pos ];
+ IvyApplication *app = *iter;
app->SendMsg(IvyApplication::DelRegexp, id, "" );
}
@@ -161,12 +164,13 @@ void Ivy::AddApplication(IvyApplication *app)
{
EnterCriticalSection( &m_application_cs );
// Check for disconnected Application
- for ( int pos = 0; pos < applications.size(); pos ++ )
+ IvyApplicationList::iterator iter;
+ for ( iter = applications.begin() ; iter != applications.end() ; )
{
- IvyApplication *disc_app = applications[ pos ];
+ IvyApplication *disc_app = *iter++;
if ( disc_app->m_hSocket == INVALID_SOCKET )
{
- //applications.erase( pos );
+ applications.remove( disc_app );
delete disc_app;
}
}
@@ -182,16 +186,11 @@ void Ivy::RemoveApplication(IvyApplication * app)
assert( TRUE );
if ( app )
{
- for ( int pos = 0; pos < applications.size(); pos ++ )
- {
- if ( app == applications[ pos ] )
- {
+
EnterCriticalSection( &m_application_cs );
- //applications.erase( pos );
+ applications.remove( app );
LeaveCriticalSection( &m_application_cs );
delete app;
- }
- }
}
}
@@ -213,9 +212,10 @@ int Ivy::SendMsg(const char * message)
{
int count = 0;
/* send to already connected */
- for ( int pos = 0 ; pos < applications.size(); pos ++ )
+ IvyApplicationList::iterator iter;
+ for ( iter = applications.begin() ; iter != applications.end() ; ++iter )
{
- IvyApplication *app = applications[ pos ];
+ IvyApplication *app = *iter;
count += app->SendMsg( message );
}
return count;
@@ -296,9 +296,10 @@ BOOL Ivy::CheckConnected(IvyApplication * app)
if (app->remoteService == 0) /* old application dont check */
return false;
/* check to see if app already connected */
- for ( int pos = 0; pos < applications.size(); pos++ )
+ IvyApplicationList::iterator iter;
+ for ( iter = applications.begin() ; iter != applications.end() ; ++iter )
{
- IvyApplication *application = applications[ pos ];
+ IvyApplication *application = *iter;
if ( application != app && application->SameApplication(app))
return true;
}