Changeset 3055 for source/ariba/Node.cpp
- Timestamp:
- Apr 23, 2009, 5:55:59 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
source/ariba/Node.cpp
r3041 r3055 41 41 #include "ariba/overlay/BaseOverlay.h" 42 42 #include "ariba/utility/types/OverlayParameterSet.h" 43 #include "ariba/interface/ServiceInterface.h"44 43 #include "ariba/communication/EndpointDescriptor.h" 45 44 … … 47 46 48 47 namespace 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 handled75 }76 77 void onNodeLeave(const NodeID& id, const SpoVNetID& spovnetid) {78 // not handled79 }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);129 48 130 49 Node::Node(AribaModule& ariba_mod, const Name& node_name) : … … 143 62 nodeId = generateNodeId(name); 144 63 145 ariba_mod.base_comm->start(ariba_mod.ip_addr, ariba_mod.tcp_port);146 base_overlay->start( *ariba_mod.base_comm, nodeId );147 148 64 const communication::EndpointDescriptor* ep = 149 65 ariba_mod.getBootstrapNode(vnetname); 150 66 if( ep == NULL ) return; 151 67 68 ariba_mod.base_comm->start(ariba_mod.ip_addr, ariba_mod.tcp_port); 69 base_overlay->start( *ariba_mod.base_comm, nodeId ); 152 70 base_overlay->joinSpoVNet( spovnetId, *ep); 153 71 } … … 173 91 base_overlay->leaveSpoVNet(); 174 92 ariba_mod.base_comm->stop(); 175 176 93 base_overlay->stop(); 177 94 } … … 222 139 223 140 void Node::bind(NodeListener* listener) { 224 base_overlay->bind(new ServiceInterfaceWrapper(listener), 225 Node::anonymousService); 141 base_overlay->bind(listener); 226 142 } 227 143 228 144 void Node::unbind(NodeListener* listener) { 229 delete base_overlay->unbind(Node::anonymousService);145 base_overlay->unbind(listener); 230 146 } 231 147 232 148 void Node::bind(CommunicationListener* listener, const ServiceID& sid) { 233 base_overlay->bind( new ServiceInterfaceWrapper(listener), sid);149 base_overlay->bind(listener, sid); 234 150 } 235 151 236 152 void Node::unbind(CommunicationListener* listener, const ServiceID& sid) { 237 delete base_overlay->unbind(sid);153 base_overlay->unbind(listener, sid); 238 154 } 239 155
Note:
See TracChangeset
for help on using the changeset viewer.