diff options
author | fcolin | 2007-02-01 12:55:42 +0000 |
---|---|---|
committer | fcolin | 2007-02-01 12:55:42 +0000 |
commit | 91aa412c2446a4b0c7abe431f4adeaa98e81acd9 (patch) | |
tree | b6eb66c86eacae34b3e67280cfd8ebe75a8e8117 /Bus | |
parent | e5f19435d916c2ed40a5455f092b012d9a9d4297 (diff) | |
download | ivy-cplusplus-91aa412c2446a4b0c7abe431f4adeaa98e81acd9.zip ivy-cplusplus-91aa412c2446a4b0c7abe431f4adeaa98e81acd9.tar.gz ivy-cplusplus-91aa412c2446a4b0c7abe431f4adeaa98e81acd9.tar.bz2 ivy-cplusplus-91aa412c2446a4b0c7abe431f4adeaa98e81acd9.tar.xz |
Utilisateur : Fcolin Date : 20/07/00 Heure : 10:57 Archivé dans $/Ivy (vss 3)
Diffstat (limited to 'Bus')
-rw-r--r-- | Bus/Ivy/Ivy.cxx | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/Bus/Ivy/Ivy.cxx b/Bus/Ivy/Ivy.cxx index fd762b6..9091264 100644 --- a/Bus/Ivy/Ivy.cxx +++ b/Bus/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;
}
|