Changeset 3055 for source/ariba/Node.cpp


Ignore:
Timestamp:
Apr 23, 2009, 5:55:59 PM (15 years ago)
Author:
Christoph Mayer
Message:

-temporärer commit, sorry kompiliert nicht :( muss aber die änderungen auf die andere maschine kriegen, ist in ca1h gefixt.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/ariba/Node.cpp

    r3041 r3055  
    4141#include "ariba/overlay/BaseOverlay.h"
    4242#include "ariba/utility/types/OverlayParameterSet.h"
    43 #include "ariba/interface/ServiceInterface.h"
    4443#include "ariba/communication/EndpointDescriptor.h"
    4544
     
    4746
    4847namespace ariba {
    49 
    50 class ServiceInterfaceWrapper: public interface::ServiceInterface {
    51 private:
    52         NodeListener* nodeListener;
    53         CommunicationListener* commListener;
    54 public:
    55         ServiceInterfaceWrapper(NodeListener* listener) :
    56                 nodeListener(listener), commListener(NULL) {
    57 
    58         }
    59 
    60         ServiceInterfaceWrapper(CommunicationListener* listener) :
    61                 nodeListener(NULL), commListener(listener) {
    62         }
    63 
    64         ~ServiceInterfaceWrapper() {
    65         }
    66 
    67 protected:
    68 
    69         bool isJoinAllowed(const NodeID& nodeid, const SpoVNetID& spovnetid) {
    70                 return true;
    71         }
    72 
    73         void onNodeJoin(const NodeID& nodeid, const SpoVNetID& spovnetid) {
    74                 // not handled
    75         }
    76 
    77         void onNodeLeave(const NodeID& id, const SpoVNetID& spovnetid) {
    78                 // not handled
    79         }
    80 
    81         void onJoinSuccess(const SpoVNetID& spovnetid) {
    82                 if (nodeListener != NULL) nodeListener->onJoinCompleted(spovnetid);
    83         }
    84 
    85         void onJoinFail(const SpoVNetID& spovnetid) {
    86                 if (nodeListener != NULL) nodeListener->onJoinFailed(spovnetid);
    87         }
    88 
    89         void onLeaveSuccess( const SpoVNetID& spovnetid ){
    90                 if (nodeListener != NULL) nodeListener->onLeaveCompleted(spovnetid);
    91         }
    92 
    93         void onLeaveFail( const SpoVNetID& spovnetid ){
    94                 if (nodeListener != NULL) nodeListener->onLeaveFailed(spovnetid);
    95         }
    96 
    97         void onLinkUp(const LinkID& link, const NodeID& local, const NodeID& remote) {
    98                 if (commListener != NULL) commListener->onLinkUp(link, remote);
    99         }
    100 
    101         void onLinkDown(const LinkID& link, const NodeID& local,
    102                         const NodeID& remote) {
    103                 if (commListener != NULL) commListener->onLinkDown(link, remote);
    104         }
    105 
    106         void onLinkChanged(const LinkID& link, const NodeID& local,
    107                         const NodeID& remote) {
    108                 if (commListener != NULL) commListener->onLinkChanged(link, remote);
    109         }
    110 
    111         void onLinkFail(const LinkID& id, const NodeID& local, const NodeID& remote) {
    112                 if (commListener != NULL) commListener->onLinkFail(id, remote);
    113         }
    114 
    115         void onLinkQoSChanged(const LinkID& id, const NodeID& local,
    116                         const NodeID& remote, const QoSParameterSet& qos) {
    117                 if (commListener != NULL) commListener->onLinkQoSChanged(id, remote,
    118                                 LinkProperties::DEFAULT);
    119         }
    120 
    121         bool receiveMessage(const Message* message, const LinkID& link,
    122                         const NodeID& node) {
    123                 if (commListener != NULL) commListener->onMessage(
    124                                 const_cast<Message*>(message), node, link);
    125         }
    126 };
    127 
    128 ServiceID Node::anonymousService = ServiceID(0xFF00);
    12948
    13049Node::Node(AribaModule& ariba_mod, const Name& node_name) :
     
    14362        nodeId = generateNodeId(name);
    14463
    145         ariba_mod.base_comm->start(ariba_mod.ip_addr, ariba_mod.tcp_port);
    146         base_overlay->start( *ariba_mod.base_comm, nodeId );
    147 
    14864        const communication::EndpointDescriptor* ep =
    14965                        ariba_mod.getBootstrapNode(vnetname);
    15066        if( ep == NULL ) return;
    15167
     68        ariba_mod.base_comm->start(ariba_mod.ip_addr, ariba_mod.tcp_port);
     69        base_overlay->start( *ariba_mod.base_comm, nodeId );
    15270        base_overlay->joinSpoVNet( spovnetId, *ep);
    15371}
     
    17391        base_overlay->leaveSpoVNet();
    17492        ariba_mod.base_comm->stop();
    175 
    17693        base_overlay->stop();
    17794}
     
    222139
    223140void Node::bind(NodeListener* listener) {
    224         base_overlay->bind(new ServiceInterfaceWrapper(listener),
    225                         Node::anonymousService);
     141        base_overlay->bind(listener);
    226142}
    227143
    228144void Node::unbind(NodeListener* listener) {
    229         delete base_overlay->unbind(Node::anonymousService);
     145        base_overlay->unbind(listener);
    230146}
    231147
    232148void Node::bind(CommunicationListener* listener, const ServiceID& sid) {
    233         base_overlay->bind(new ServiceInterfaceWrapper(listener), sid);
     149        base_overlay->bind(listener, sid);
    234150}
    235151
    236152void Node::unbind(CommunicationListener* listener, const ServiceID& sid) {
    237         delete base_overlay->unbind(sid);
     153        base_overlay->unbind(listener, sid);
    238154}
    239155
Note: See TracChangeset for help on using the changeset viewer.