[Jderobot-admin] jderobot-r1204 - trunk/src/stable/libs/ns

rocapal en jderobot.org rocapal en jderobot.org
Mie Mar 19 13:18:36 CET 2014


Author: rocapal
Date: 2014-03-19 13:18:36 +0100 (Wed, 19 Mar 2014)
New Revision: 1204

Modified:
   trunk/src/stable/libs/ns/ns.cpp
   trunk/src/stable/libs/ns/ns.h
Log:
#195 Added unbindAll method


Modified: trunk/src/stable/libs/ns/ns.cpp
===================================================================
--- trunk/src/stable/libs/ns/ns.cpp	2014-03-18 16:47:44 UTC (rev 1203)
+++ trunk/src/stable/libs/ns/ns.cpp	2014-03-19 12:18:36 UTC (rev 1204)
@@ -59,6 +59,8 @@
 					node->ip + ":" + boost::lexical_cast<std::string>(node->port) );
 
 	mNamingService->bind(node);
+
+	mBinds.push_back(node->name);
 }
 
 void ns::unbind (std::string name)
@@ -68,8 +70,25 @@
 	node->name = name;
 
 	mNamingService->unbind(node);
+
+	for (std::vector<std::string>::iterator it = mBinds.begin(); it != mBinds.end(); it++)
+	{
+		if (name.compare(*it))
+			mBinds.erase(it);
+	}
 }
 
+void ns::unbindAll()
+{
+	NamingNodePtr node = new NamingNode();
+	for (std::vector<std::string>::iterator it = mBinds.begin(); it != mBinds.end(); it++)
+	{
+		node->name = *it;
+		mNamingService->unbind(node);
+	}
+	mBinds.clear();
+}
+
 jderobot::NodeContainerPtr ns::resolveByName(std::string name)
 {
 	return mNamingService->resolveByName(name);

Modified: trunk/src/stable/libs/ns/ns.h
===================================================================
--- trunk/src/stable/libs/ns/ns.h	2014-03-18 16:47:44 UTC (rev 1203)
+++ trunk/src/stable/libs/ns/ns.h	2014-03-19 12:18:36 UTC (rev 1204)
@@ -67,6 +67,13 @@
 		void unbind (std::string name);
 
 		/**
+		 * \brief Send unbind petition to every component register
+		 *
+		 */
+		void unbindAll();
+
+
+		/**
 		 * \brief Send a resolve petition given a name of component
 		 *
 		 * @param name The name of component to search
@@ -93,6 +100,8 @@
 
 		NamingServicePrx mNamingService;
 
+		std::vector<std::string> mBinds;
+
 		std::vector<std::string>& split(const std::string &s, char delim, std::vector<std::string> &elems);
 	};
 



More information about the Jderobot-admin mailing list