Ignore:
Timestamp:
May 7, 2009, 4:51:31 PM (15 years ago)
Author:
Christoph Mayer
Message:

-Integration of Branch 20090424-mayer-sideport

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/ariba/overlay/BaseOverlay.cpp

    r3071 r3374  
    4242#include "ariba/NodeListener.h"
    4343#include "ariba/CommunicationListener.h"
     44#include "ariba/SideportListener.h"
    4445
    4546namespace ariba {
     
    4950
    5051BaseOverlay::BaseOverlay()
    51         : bc(NULL), overlayInterface(NULL),
    52                 nodeId(NodeID::UNSPECIFIED), spovnetId(SpoVNetID::UNSPECIFIED),
    53                 initiatorLink(LinkID::UNSPECIFIED), state(BaseOverlayStateInvalid){
     52        : bc(NULL), overlayInterface(NULL), nodeId(NodeID::UNSPECIFIED),
     53                spovnetId(SpoVNetID::UNSPECIFIED), initiatorLink(LinkID::UNSPECIFIED),
     54                state(BaseOverlayStateInvalid), sideport(&SideportListener::DEFAULT){
    5455}
    5556
     
    230231
    231232        CommunicationListener* receiver = communicationListeners.get( service );
     233        assert( receiver != NULL );
     234
    232235        LinkItem item (link, NodeID::UNSPECIFIED, service, receiver);
    233236        linkMapping.insert( make_pair(link, item) );
     
    251254        bc->dropLink( link );
    252255
    253         if( item.interface != NULL )
    254                 item.interface->onLinkDown( link, item.node );
     256        item.interface->onLinkDown( link, item.node );
     257        sideport->onLinkDown(link, this->nodeId, item.node, this->spovnetId );
    255258}
    256259
     
    352355        communicationListeners.registerItem( listener, sid );
    353356        return true;
     357}
     358
     359bool BaseOverlay::registerSidePort(SideportListener* _sideport){
     360        sideport = _sideport;
     361        _sideport->configure( this );
     362}
     363
     364bool BaseOverlay::unregisterSidePort(SideportListener* _sideport){
     365        sideport = &SideportListener::DEFAULT;
    354366}
    355367
     
    442454        if( i == linkMapping.end() ){
    443455
    444                 LinkItem item (id, NodeID::UNSPECIFIED, ServiceID::UNSPECIFIED, NULL );
     456                LinkItem item (id, NodeID::UNSPECIFIED, ServiceID::UNSPECIFIED, &CommunicationListener::DEFAULT );
    445457                linkMapping.insert( make_pair(id, item) );
    446458
     
    487499        }
    488500
    489         if( i->second.interface != NULL )
    490                 i->second.interface->onLinkDown( id, i->second.node );
     501        i->second.interface->onLinkDown( id, i->second.node );
     502        sideport->onLinkDown( id, this->nodeId, i->second.node, this->spovnetId );
    491503
    492504        linkMapping.erase( i );
     
    504516        if( i == linkMapping.end() ) return;
    505517
    506         if( i->second.interface != NULL ){
    507                 i->second.interface->onLinkChanged( id, i->second.node );
    508                 // call onLinkQoSChanged?
    509         }
     518        i->second.interface->onLinkChanged( id, i->second.node );
     519        sideport->onLinkChanged( id, this->nodeId, i->second.node, this->spovnetId );
     520
     521        // TODO call onLinkQoSChanged?
    510522
    511523        i->second.markused();
     
    523535        if( i == linkMapping.end() ) return;
    524536
    525         if( i->second.interface != NULL )
    526                 i->second.interface->onLinkFail( id, i->second.node );
     537        i->second.interface->onLinkFail( id, i->second.node );
     538        sideport->onLinkFail( id, this->nodeId, i->second.node, this->spovnetId );
    527539
    528540        i->second.markused();
     
    541553
    542554        // TODO: convert QoSParameterSet to the LinkProperties properties
    543         if( i->second.interface != NULL ){
    544                 // TODO: currently not in the interface: i->second.interface->onLinkQoSChanged( id, i->second.node, LinkProperties::DEFAULT );
    545         }
     555        // TODO: currently not in the interface: i->second.interface->onLinkQoSChanged( id, i->second.node, LinkProperties::DEFAULT );
    546556
    547557        i->second.markused();
     
    799809
    800810                CommunicationListener* iface = communicationListeners.get( service );
    801                 if( iface == NULL ){
     811                if( iface == NULL || iface == &CommunicationListener::DEFAULT ){
    802812                        logging_warn( "linkup event for service that has been registered with a NULL interface" );
    803813                        return true;
     
    812822
    813823                if( iface->onLinkRequest(sourcenode) ){
     824
     825                        // call the notification functions
    814826                        iface->onLinkUp( link, sourcenode );
     827                        sideport->onLinkUp( link, nodeId, sourcenode, this->spovnetId );
     828
    815829                } else {
    816830                        // prevent onLinkDown calls to the service
    817                         i->second.interface = NULL;
     831                        i->second.interface = &CommunicationListener::DEFAULT;
    818832                        // drop the link
    819833                        dropLink( link );
     
    950964}
    951965
     966vector<LinkID> BaseOverlay::getLinkIDs( const NodeID& nid ) const {
     967
     968        vector<LinkID> linkvector;
     969
     970        BOOST_FOREACH( LinkPair item, linkMapping ){
     971                if( item.second.node == nid || nid == NodeID::UNSPECIFIED ){
     972                        linkvector.push_back( item.second.link );
     973                }
     974        }
     975
     976        return linkvector;
     977}
     978
    952979void BaseOverlay::incomingRouteMessage(Message* msg){
    953980        // gets handled as normal data message
Note: See TracChangeset for help on using the changeset viewer.