Changeset 3056 for source/ariba
- Timestamp:
- Apr 23, 2009, 6:58:34 PM (16 years ago)
- Location:
- source/ariba
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/CommunicationListener.cpp
r3055 r3056 65 65 bool CommunicationListener::onLinkRequest(const NodeID& remote, 66 66 const DataMessage& msg) { 67 return false;67 return true; 68 68 } 69 69 … … 72 72 } 73 73 74 // --- extended message functionality --- 74 75 // void CommunicationListener::onMessageSent(seqnum_t seq_num, bool failed, 75 76 // const DataMessage& msg) { -
source/ariba/CommunicationListener.h
r3055 r3056 40 40 #define COMMUNICATIONLISTENER_H_ 41 41 42 namespace ariba {43 // forward declaration44 class CommunicationListener;45 }46 47 42 #include "Message.h" 48 43 #include "Identifiers.h" … … 52 47 namespace ariba { 53 48 49 // forward decl 50 namespace overlay { 51 class BaseOverlay; 52 } 53 54 54 /** 55 55 * Listener for communication events on links. 56 56 */ 57 57 class CommunicationListener { 58 friend class Node;58 friend class ariba::overlay::BaseOverlay; 59 59 protected: 60 60 CommunicationListener(); -
source/ariba/NodeListener.h
r3055 r3056 40 40 #define NODELISTENER_H_ 41 41 42 // forward declaration43 namespace ariba {44 class NodeListener;45 class Node;46 }47 48 42 #include "Identifiers.h" 49 43 50 44 namespace ariba { 45 46 // forward decl 47 namespace overlay { 48 class BaseOverlay; 49 } 51 50 52 51 /** … … 57 56 */ 58 57 class NodeListener { 59 friend class Node;58 friend class ariba::overlay::BaseOverlay; 60 59 public: 61 60 NodeListener(); 62 61 virtual ~NodeListener(); 62 63 63 protected: 64 64 /** -
source/ariba/overlay/BaseOverlay.cpp
r3055 r3056 148 148 // inform all registered services of the event 149 149 BOOST_FOREACH( NodeListener* i, nodeListeners ){ 150 if( ret ) i->onLeave Success( spovnetId );151 else i->onLeaveFail ( spovnetId );150 if( ret ) i->onLeaveCompleted( spovnetId ); 151 else i->onLeaveFailed( spovnetId ); 152 152 } 153 153 } … … 178 178 overlayInterface->joinOverlay(); 179 179 BOOST_FOREACH( NodeListener* i, nodeListeners ){ 180 i->onJoin Success( spovnetId );180 i->onJoinCompleted( spovnetId ); 181 181 } 182 182 … … 252 252 253 253 if( item.interface != NULL ) 254 item.interface->onLinkDown( spovnetId, nodeId, item.node );254 item.interface->onLinkDown( link, item.node ); 255 255 } 256 256 … … 310 310 311 311 void BaseOverlay::bind(CommunicationListener* listener, const ServiceID& sid){ 312 logging_debug( "binding communication listener " << listener 312 logging_debug( "binding communication listener " << listener 313 313 << " on serviceid " << sid.toString() ); 314 314 315 315 if( communicationListeners.contains( sid ) ){ 316 logging_error( "some listener already registered for service id " 316 logging_error( "some listener already registered for service id " 317 317 << sid.toString() ); 318 return false;318 return; 319 319 } 320 320 321 321 communicationListeners.registerItem( listener, sid ); 322 return true;323 322 } 324 323 325 324 void BaseOverlay::unbind(CommunicationListener* listener, const ServiceID& sid){ 326 logging_debug( "unbinding listener " << listener 325 logging_debug( "unbinding listener " << listener 327 326 << " from serviceid " << sid.toString() ); 328 327 … … 333 332 334 333 if( communicationListeners.get(sid) != listener ){ 335 logging_warn( "listener bound to service id " << sid.toString() 334 logging_warn( "listener bound to service id " << sid.toString() 336 335 << " is different than listener trying to unbind" ); 337 336 return; … … 344 343 logging_debug( "binding node listener " << listener ); 345 344 346 NodeListenerVector::iterator i = nodeListeners.find(listener );345 NodeListenerVector::iterator i = find( nodeListeners.begin(), nodeListeners.end(), listener ); 347 346 if( i != nodeListeners.end() ){ 348 347 logging_warn( "node listener " << listener << " is already bound, cannot bind" ); 349 348 return; 350 349 } 351 350 352 351 nodeListeners.push_back( listener ); 353 352 } … … 356 355 logging_debug( "unbinding node listener " << listener ); 357 356 358 NodeListenerVector::iterator i = nodeListeners.find(listener );357 NodeListenerVector::iterator i = find( nodeListeners.begin(), nodeListeners.end(), listener ); 359 358 if( i == nodeListeners.end() ){ 360 359 logging_warn( "node listener " << listener << " is not bound, cannot unbind" ); 361 360 return; 362 361 } 363 362 364 363 nodeListeners.erase( i ); 365 364 } … … 451 450 452 451 if( i->second.interface != NULL ) 453 i->second.interface->onLinkDown( id, nodeId,i->second.node );452 i->second.interface->onLinkDown( id, i->second.node ); 454 453 455 454 linkMapping.erase( i ); … … 468 467 469 468 if( i->second.interface != NULL ) 470 i->second.interface->onLinkChanged( id, nodeId,i->second.node );469 i->second.interface->onLinkChanged( id, i->second.node ); 471 470 472 471 i->second.markused(); … … 485 484 486 485 if( i->second.interface != NULL ) 487 i->second.interface->onLinkFail( id, nodeId,i->second.node );486 i->second.interface->onLinkFail( id, i->second.node ); 488 487 489 488 i->second.markused(); … … 501 500 if( i == linkMapping.end() ) return; 502 501 502 // TODO: convert QoSParameterSet to the LinkProperties properties 503 503 if( i->second.interface != NULL ) 504 i->second.interface->onLinkQoSChanged( id, nodeId, i->second.node, qos);504 i->second.interface->onLinkQoSChanged( id, i->second.node, LinkProperties::DEFAULT ); 505 505 506 506 i->second.markused(); … … 535 535 536 536 if( serviceListener != NULL ) 537 serviceListener-> receiveMessage( overlayMsg, link, overlayMsg->getSourceNode());537 serviceListener->onMessage( overlayMsg, overlayMsg->getSourceNode(), link ); 538 538 539 539 return true; … … 571 571 // 572 572 573 // TODO: here you can implement mechanisms to deny joining of a node 573 574 bool allow = true; 574 575 BOOST_FOREACH( NodeListener* i, nodeListeners ){576 allow &= i->isJoinAllowed( overlayMsg->getSourceNode(), spovnetId );577 }578 575 579 576 logging_info( "sending back join reply for spovnet " << … … 644 641 645 642 // inform all registered services of the event 646 BOOST_FOREACH( NodeListener* i, nodeListeners {647 i->onJoinFail ( spovnetId );643 BOOST_FOREACH( NodeListener* i, nodeListeners ){ 644 i->onJoinFailed( spovnetId ); 648 645 } 649 646 … … 670 667 // inform all registered services of the event 671 668 BOOST_FOREACH( NodeListener* i, nodeListeners ){ 672 i->onJoinFail ( spovnetId );669 i->onJoinFailed( spovnetId ); 673 670 } 674 671 … … 692 689 // inform all registered services of the event 693 690 BOOST_FOREACH( NodeListener* i, nodeListeners ){ 694 i->onJoin Success( spovnetId );691 i->onJoinCompleted( spovnetId ); 695 692 } 696 693 … … 758 755 759 756 i->second.interface = iface; 760 iface->onLinkUp( link, nodeId,sourcenode );757 iface->onLinkUp( link, sourcenode ); 761 758 i->second.markused(); 762 759 … … 792 789 // inform all registered services of the event 793 790 BOOST_FOREACH( NodeListener* i, nodeListeners ){ 794 i->onLeaveFail ( spovnetId );791 i->onLeaveFailed( spovnetId ); 795 792 } 796 793 … … 802 799 logging_info( "node left " << overlayMsg->getSourceNode() ); 803 800 804 // inform all registered services of the event805 BOOST_FOREACH( NodeListener* i, nodeListeners ){806 i->onNodeLeave( overlayMsg->getSourceNode(), spovnetId );807 }808 801 } 809 802 … … 908 901 << node.toString() ); 909 902 910 BOOST_FOREACH( NodeListener* i, nodeListeners ){911 i->onNodeJoin( node, spovnetId );912 }913 914 903 joiningNodes.erase( i ); 915 904 } -
source/ariba/overlay/BaseOverlay.h
r3055 r3056 70 70 class NodeListener; 71 71 class CommunicationListener; 72 73 72 namespace utility { 74 73 class OvlVis; … … 204 203 */ 205 204 void bind(CommunicationListener* listener, const ServiceID& sid); 206 205 207 206 /** 208 207 * TODO 209 208 */ 210 209 void unbind(CommunicationListener* listener, const ServiceID& sid); 211 210 212 211 /** 213 212 * TODO 214 213 */ 215 214 void bind(NodeListener* listener); 216 215 217 216 /** 218 217 * TODO … … 289 288 */ 290 289 virtual void incomingRouteMessage( Message* msg ); 291 290 292 291 /** 293 292 * see OverlayStructureEvents.h, called from specific OverlayInterface class … … 295 294 virtual void onNodeJoin( const NodeID& node ); 296 295 297 296 298 297 /** 299 298 * TODO, for timer events … … 407 406 LinkMapping linkMapping; 408 407 409 410 /** 411 * nodes with pending joines. TODO: should be cleaned every 408 409 /** 410 * nodes with pending joines. TODO: should be cleaned every 412 411 * some seconds, add timestamps to each, and check on occasion 413 412 */ -
source/ariba/overlay/modules/OverlayInterface.cpp
r2473 r3056 57 57 58 58 OverlayInterface::~OverlayInterface(){ 59 baseoverlay.unbind( OVERLAY_SERVICE_ID );59 baseoverlay.unbind( this, OVERLAY_SERVICE_ID ); 60 60 } 61 61
Note:
See TracChangeset
for help on using the changeset viewer.