Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | Related Pages | Examples

ColCOWS_EventHandlerManager.cc

00001 //===========================================================================//
00002 //    
00003 //    Description: interface for user defined event handling classes
00004 //    Filename: colcows/ColCOWS_EventHandlerManager.hh
00005 //    Authors: Michael Dussere and Aurélien Esnard
00006 //    
00007 //===========================================================================//
00008 //    
00009 //    Copyright (C) 2003 INRIA and CNRS
00010 //    
00011 //    This library is free software; you can redistribute it and/or
00012 //    modify it under the terms of the GNU Lesser General Public
00013 //    License as published by the Free Software Foundation; either
00014 //    version 2.1 of the License, or (at your option) any later version.
00015 //    
00016 //    This library is distributed in the hope that it will be useful,
00017 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 //    Lesser General Public License for more details.
00020 //    
00021 //    You should have received a copy of the GNU Lesser General Public
00022 //    License along with this library; if not, write to the Free Software
00023 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024 //    
00025 //===========================================================================//
00026 
00027 #include "ColCOWS_EventHandlerManager.hh" 
00028 #include "ColCOWS_EventHandler.hh" 
00029 #include "ColCOWS_Corba.hh" 
00030 
00031 using namespace std;
00032 
00033 __COLCOWS_BEGIN__
00034 
00035 
00036 //===========================================================================//
00037 
00038 EventHandlerManager::EventHandlerManager()
00039 {
00040   COLCOWS_IN_DEBUG();
00041 
00042   _max_key = 0;
00043 
00044   COLCOWS_OUT_DEBUG();
00045   return;
00046 }
00047   
00048 //===========================================================================//
00049 
00050 EventHandlerManager::~EventHandlerManager()
00051 {
00052   COLCOWS_IN_DEBUG();
00053 
00054   COLCOWS_OUT_DEBUG();
00055   return;
00056 }
00057 
00058 //===========================================================================//
00059 
00060 unsigned int EventHandlerManager::addEventHandler( EventHandler * event_handler ) 
00061 { 
00062   COLCOWS_IN_DEBUG();
00063 
00064   COLCOWS_ASSERT( (event_handler->getKey() == 0), "event handler already managed." << "Key = " << event_handler->getKey() );
00065 
00066   _max_key ++;
00067   event_handler->setKey( _max_key );
00068   event_handler->setEventHandlerManager( this );
00069   insert( make_pair( _max_key, event_handler ) );
00070 
00071   COLCOWS_OUT_DEBUG();
00072   return _max_key;    
00073 }
00074 
00075 //===========================================================================//
00076 
00077 void EventHandlerManager::removeEventHandler( unsigned int key ) 
00078 { 
00079   COLCOWS_IN_DEBUG();
00080 
00081   iterator it = find(key);
00082   COLCOWS_ASSERT( (it != end()), "event handler is not managed by this manager.");
00083 
00084   it->second->setKey( 0 );
00085   it->second->setEventHandlerManager( NULL );
00086 
00087   erase(it);
00088 
00089   COLCOWS_OUT_DEBUG();
00090   return;    
00091 }
00092 
00093 //===========================================================================//
00094 
00095 void EventHandlerManager::onActivation() 
00096 {
00097   COLCOWS_IN_DEBUG();
00098 
00099   iterator it_begin = begin();
00100   iterator it_end = end();
00101   
00102   for ( iterator it = it_begin; it != it_end; ++it )
00103     {
00104       it->second->onActivation();
00105     }
00106   
00107   COLCOWS_OUT_DEBUG();
00108   return;    
00109 }
00110 
00111 //===========================================================================//
00112 
00113 void EventHandlerManager::onDeactivation() 
00114 {
00115   COLCOWS_IN_DEBUG();
00116 
00117   iterator it_begin = begin();
00118   iterator it_end = end();
00119   
00120   for ( iterator it = it_begin; it != it_end; ++it )
00121     {
00122       it->second->onDeactivation();
00123     }
00124 
00125   COLCOWS_OUT_DEBUG();
00126   return;
00127 }
00128 
00129 //===========================================================================//
00130 
00131 void EventHandlerManager::onConnection( unsigned long num_connection, bool initiator ) 
00132 {
00133   COLCOWS_IN_DEBUG();
00134 
00135   iterator it_begin = begin();
00136   iterator it_end = end();
00137   
00138   for ( iterator it = it_begin; it != it_end; ++it )
00139     {
00140       it->second->onConnection( num_connection, initiator );
00141     }
00142 
00143   COLCOWS_OUT_DEBUG();
00144   return;
00145 }
00146 
00147 //===========================================================================//
00148 
00149 void EventHandlerManager::onDisconnection( unsigned long num_connection ) 
00150 {
00151   COLCOWS_IN_DEBUG();
00152 
00153   iterator it_begin = begin();
00154   iterator it_end = end();
00155   
00156   for ( iterator it = it_begin; it != it_end; ++it )
00157     {
00158       it->second->onDisconnection( num_connection );
00159     }
00160 
00161   COLCOWS_OUT_DEBUG();
00162   return;
00163 }
00164 
00165 //===========================================================================//
00166 
00167 __COLCOWS_END__
00168 
00169 // EOF
00170 

Generated on Tue Jun 21 12:55:56 2005 for ColCOWS by  doxygen 1.4.1