Index: source/ariba/overlay/BaseOverlay.h
===================================================================
--- source/ariba/overlay/BaseOverlay.h	(revision 3041)
+++ source/ariba/overlay/BaseOverlay.h	(revision 3055)
@@ -59,6 +59,4 @@
 #include "ariba/communication/CommunicationEvents.h"
 
-#include "ariba/interface/ServiceInterface.h"
-
 #include "ariba/overlay/modules/OverlayInterface.h"
 #include "ariba/overlay/modules/OverlayFactory.h"
@@ -67,4 +65,14 @@
 #include "ariba/overlay/messages/JoinRequest.h"
 #include "ariba/overlay/messages/JoinReply.h"
+
+// forward declerations
+namespace ariba {
+	class NodeListener;
+	class CommunicationListener;
+
+	namespace utility {
+		class OvlVis;
+	}
+}
 
 using std::vector;
@@ -76,9 +84,10 @@
 using std::find;
 
+using ariba::NodeListener;
+using ariba::CommunicationListener;
+
 using ariba::communication::EndpointDescriptor;
 using ariba::communication::BaseCommunication;
 using ariba::communication::CommunicationEvents;
-
-using ariba::interface::ServiceInterface;
 
 using ariba::overlay::OverlayMsg;
@@ -101,13 +110,8 @@
 using ariba::utility::seqnum_t;
 using ariba::utility::Timer;
+using ariba::utility::OvlVis;
 
 #define ovl OvlVis::instance()
 #define ovlId OvlVis::NETWORK_ID_BASE_OVERLAY
-
-// needed for friend decleration
-// in different namespace
-namespace ariba {
-	class Node;
-}
 
 namespace ariba {
@@ -121,8 +125,5 @@
 
 	use_logging_h( BaseOverlay );
-	friend class ariba::Node;
-
 public:
-
 	/**
 	 * Constructs an empty non-functional base overlay instance
@@ -147,11 +148,14 @@
 	/**
 	 * Starts a link establishment procedure to the specfied node
+	 * for the service with id service
 	 *
-	 * @param node The node id
+	 * @param node Destination node id
+	 * @param service Service to connect to
 	 */
 	const LinkID establishLink( const NodeID& node, const ServiceID& service );
 
 	/**
-	 * TODO
+	 * Starts a link establishment procedure to the specified
+	 * endpoint and to the specified service
 	 */
 	const LinkID establishLink( const EndpointDescriptor& ep, const ServiceID& service );
@@ -176,8 +180,5 @@
 	 * Depending on the structure of the overlay, this can be very different.
 	 */
-	void broadcastMessage(
-		Message* message,
-		const ServiceID& service
-	);
+	void broadcastMessage( Message* message, const ServiceID& service );
 
 	/**
@@ -200,16 +201,22 @@
 
 	/**
-	 * Registers a receiver.
-	 *
-	 * @param receiver An implementation of the receiver interface
-	 */
-	bool bind( ServiceInterface* service, const ServiceID& sid );
-
-	/**
-	 * Unregister a receiver.
-	 *
-	 * @param sid The service id to unregister
-	 */
-	ServiceInterface* unbind( const ServiceID& sid );
+	 * TODO
+	 */
+	void bind(CommunicationListener* listener, const ServiceID& sid);
+	
+	/**
+	 * TODO
+	 */
+	void unbind(CommunicationListener* listener, const ServiceID& sid);
+	
+	/**
+	 * TODO
+	 */
+	void bind(NodeListener* listener);
+	
+	/**
+	 * TODO
+	 */
+	void unbind(NodeListener* listener);
 
 	/**
@@ -221,15 +228,12 @@
 	const NodeID& getNodeID( const LinkID& lid = LinkID::UNSPECIFIED ) const ;
 
-protected:
-
-	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-	void joinSpoVNet(
-		const SpoVNetID& id,
-		const EndpointDescriptor& bootstrapEp
-	);
-
+	/**
+	 * TODO
+	 */
+	void joinSpoVNet( const SpoVNetID& id, const EndpointDescriptor& bootstrapEp );
+
+	/**
+	 * TODO
+	 */
 	void createSpoVNet(
 		const SpoVNetID& id,
@@ -239,19 +243,31 @@
 	);
 
-	void leaveSpoVNet(
-	);
-
-	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
+	/**
+	 * TODO
+	 */
+	void leaveSpoVNet();
+
+protected:
+
+	/**
+	 * TODO
+	 */
 	virtual void onLinkUp( const LinkID& id, const NetworkLocator* local, const NetworkLocator* remote );
 
+	/**
+	 * TODO
+	 */
 	virtual void onLinkDown( const LinkID& id, const NetworkLocator* local, const NetworkLocator* remote );
 
 	virtual void onLinkChanged( const LinkID& id, const NetworkLocator* oldlocal, const NetworkLocator* newlocal, const NetworkLocator* oldremote, const NetworkLocator* newremote );
 
+	/**
+	 * TODO
+	 */
 	virtual void onLinkFail( const LinkID& id, const NetworkLocator* local, const NetworkLocator* remote );
 
+	/**
+	 * TODO
+	 */
 	virtual void onLinkQoSChanged( const LinkID& id, const NetworkLocator* local, const NetworkLocator* remote, const QoSParameterSet& qos );
 
@@ -260,4 +276,7 @@
 	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+	/**
+	 * TODO
+	 */
 	virtual bool receiveMessage( const Message* message, const LinkID& link, const NodeID& ); // nodeid is not valid in this case!
 
@@ -270,11 +289,17 @@
 	 */
 	virtual void incomingRouteMessage( Message* msg );
+	
+	/**
+	 * see OverlayStructureEvents.h, called from specific OverlayInterface class
+	 */
 	virtual void onNodeJoin( const NodeID& node );
 
-	// for timer events
+	
+	/**
+	 * TODO, for timer events
+	 */
 	virtual void eventFunction();
 
 private:
-
 	/**
 	 * The BaseCommunication the BaseOverlay
@@ -295,8 +320,17 @@
 
 	/**
-	 * A demultiplexer that maps listeners to service ids
-	 * to deliver upcoming messages to the correct service.
-	 */
-	Demultiplexer<ServiceInterface*, ServiceID> listenerMux;
+	 * TODO
+	 */
+	Demultiplexer<CommunicationListener*, ServiceID> communicationListeners;
+
+	/**
+	 * TODO
+	 */
+	typedef vector<NodeListener*> NodeListenerVector;
+
+	/**
+	 * TODO
+	 */
+	NodeListenerVector nodeListeners;
 
 	/**
@@ -322,4 +356,7 @@
 	} BaseOverlayState;
 
+	/**
+	 * TODO
+	 */
 	BaseOverlayState state;
 
@@ -344,5 +381,5 @@
 
 		LinkItem( const LinkID& _link, const NodeID& _node,
-				const ServiceID& _service, ServiceInterface* _interface )
+				const ServiceID& _service, CommunicationListener* _interface )
 			: link( _link ), node( _node ), service( _service ), interface( _interface ),
 				autolink( false ), lastuse( time(NULL) ) {
@@ -354,5 +391,5 @@
 		NodeID node;
 		ServiceID service;
-		ServiceInterface* interface;
+		CommunicationListener* interface;
 
 		// information needed for auto links
@@ -370,6 +407,9 @@
 	LinkMapping linkMapping;
 
-	// nodes with pending joines. TODO: should be cleaned every some seconds
-	// add timestamps to each, and check on occasion
+	
+	/**
+	 * nodes with pending joines. TODO: should be cleaned every 
+	 * some seconds, add timestamps to each, and check on occasion
+	 */
 	typedef vector<NodeID> JoiningNodes;
 	JoiningNodes joiningNodes;
