summaryrefslogtreecommitdiff
path: root/Ivy
diff options
context:
space:
mode:
Diffstat (limited to 'Ivy')
-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;
}