[hydra-commits] hydra/servicediscovery.git branch "master" updated.

Commits to the Hydra project code repositories hydra-commits at lists.digium.com
Tue Aug 3 18:17:33 CDT 2010


branch "master" has been updated
       via  2378b0d1916307afa63d153af41f312d5836ddac (commit)
       via  01f78763616934ce98bbbf30035f3e39dd87c027 (commit)
       via  f7276bbcac627e39ac97fa9c3fa240a75ee70868 (commit)
      from  49307005f3b586500cb3d1ce2a0f9eeb10e1a3cd (commit)

Summary of changes:
 src/CMakeLists.txt               |    2 +-
 src/ServiceLocator.cpp           |   20 +++--
 src/ServiceLocatorManagement.cpp |  138 ++++++++++++++++++++++++++++-------
 src/ServiceLocatorManagement.h   |   62 ++-------------
 src/ServiceManagement.cpp        |  151 ++++++++++++++++++++++++++++++++-----
 src/ServiceManagement.h          |   87 ++-------------------
 6 files changed, 273 insertions(+), 187 deletions(-)


- Log -----------------------------------------------------------------
commit 2378b0d1916307afa63d153af41f312d5836ddac
Author: Joshua Colp <jcolp at digium.com>
Date:   Tue Aug 3 20:33:22 2010 -0300

    One word: pimpl.

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ee51c0b..653b6ea 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -6,6 +6,6 @@ hydra_component_add_file(service_locator ServiceLocator.cpp)
 hydra_component_add_file(service_locator ServiceLocatorManagement.cpp)
 hydra_component_add_file(service_locator ServiceManagement.cpp)
 hydra_component_add_ice_libraries(service_locator IceStorm)
-hydra_component_add_boost_libraries(service_locator thread)
+hydra_component_add_boost_libraries(service_locator core thread)
 hydra_component_build_standalone(service_locator)
 hydra_component_install(service_locator RUNTIME bin "Service Locator." Core)
diff --git a/src/ServiceLocator.cpp b/src/ServiceLocator.cpp
index e34a33d..64c1965 100644
--- a/src/ServiceLocator.cpp
+++ b/src/ServiceLocator.cpp
@@ -19,8 +19,6 @@
 #include <Ice/Ice.h>
 #include <IceStorm/IceStorm.h>
 
-#include <boost/thread/shared_mutex.hpp>
-
 #include "service_locator.h"
 #include "service_locator_events.h"
 
diff --git a/src/ServiceLocatorManagement.cpp b/src/ServiceLocatorManagement.cpp
index 73b196f..b203d2a 100644
--- a/src/ServiceLocatorManagement.cpp
+++ b/src/ServiceLocatorManagement.cpp
@@ -31,10 +31,74 @@ using namespace Hydra::System::Location;
 using namespace Hydra::System::Location::V1;
 
 /**
+ * Small internal class which is used to store information about a comparator.
+ */
+class ServiceLocatorComparator
+{
+public:
+	/**
+	 * Constructor for the ServiceLocatorComparator class.
+	 *
+	 * @param compare A proxy to the comparator service we are wrapping.
+	 */
+	ServiceLocatorComparator(const Hydra::System::Location::V1::ServiceLocatorParamsComparePrx& compare) : mCompare(compare) { };
+
+	/**
+	 * API call which forwards an isSupported over ICE to a remote comparator.
+	 *
+	 * @param params Service locator parameters that describe a locator request.
+	 *
+	 * @return A boolean value with true indicating the parameters are supported while false indicates otherwise.
+	 */
+	bool isSupported(const Hydra::System::Location::V1::ServiceLocatorParamsPtr& params) { return mCompare->isSupported(params); };
+private:
+	/**
+	 * A proxy to the comparator service that we are wrapping.
+	 */
+	Hydra::System::Location::V1::ServiceLocatorParamsComparePrx mCompare;
+};
+
+/**
+ * Small internal class which is used to store private details for ServiceLocatorManagementImpl.
+ */
+class ServiceLocatorManagementImplPriv : public Ice::Object
+{
+public:
+	ServiceLocatorManagementImplPriv(Ice::ObjectAdapterPtr adapter, const Hydra::System::Location::EventsPrx& service_discovery_topic) :
+		mAdapter(adapter), mLocatorTopic(service_discovery_topic) { };
+	/**
+	 * Shared mutex lock which protects the services and comparators.
+	 */
+	boost::shared_mutex mLock;
+
+	/**
+	 * Object adapter that our service management proxies originate from, it is houses the
+	 * main management service.
+	 */
+	Ice::ObjectAdapterPtr mAdapter;
+
+	/**
+	 * A map of all the comparators that have been added by external components. The key
+	 * is the unique identifier that they add themselves with.
+	 */
+	std::map<std::string, ServiceLocatorComparator> mCompares;
+
+	/**
+	 * A vector of all the services that have been added.
+	 */
+	std::vector<ServiceManagementImplPtr> mServices;
+
+	/**
+	 * A proxy that can be used to publish locator events.
+	 */
+	Hydra::System::Location::EventsPrx mLocatorTopic;
+};
+
+/**
  * Implementation of a constructor for the ServiceLocatorManagementImpl class.
  */
 ServiceLocatorManagementImpl::ServiceLocatorManagementImpl(Ice::ObjectAdapterPtr adapter, const Hydra::System::Location::EventsPrx& service_discovery_topic)
-        : mAdapter(adapter), mLocatorTopic(service_discovery_topic)
+        : mImpl(new ServiceLocatorManagementImplPriv(adapter, service_discovery_topic))
 {
 }
 
@@ -43,9 +107,9 @@ ServiceLocatorManagementImpl::ServiceLocatorManagementImpl(Ice::ObjectAdapterPtr
  */
 Ice::ObjectPrx ServiceLocatorManagementImpl::locate(const ServiceLocatorParamsPtr& params)
 {
-	boost::shared_lock<boost::shared_mutex> lock(mLock);
+	boost::shared_lock<boost::shared_mutex> lock(mImpl->mLock);
 
-	for (vector<ServiceManagementImplPtr>::iterator service = mServices.begin(); service != mServices.end(); ++service)
+	for (vector<ServiceManagementImplPtr>::iterator service = mImpl->mServices.begin(); service != mImpl->mServices.end(); ++service)
 	{
 		if ((*service)->isSupported(params) == true)
 		{
@@ -61,10 +125,10 @@ Ice::ObjectPrx ServiceLocatorManagementImpl::locate(const ServiceLocatorParamsPt
  */
 Ice::ObjectProxySeq ServiceLocatorManagementImpl::locateAll(const ServiceLocatorParamsPtr& params)
 {
-	boost::shared_lock<boost::shared_mutex> lock(mLock);
+	boost::shared_lock<boost::shared_mutex> lock(mImpl->mLock);
 	Ice::ObjectProxySeq applicable_services;
 
-	for (vector<ServiceManagementImplPtr>::iterator service = mServices.begin(); service != mServices.end(); ++service)
+	for (vector<ServiceManagementImplPtr>::iterator service = mImpl->mServices.begin(); service != mImpl->mServices.end(); ++service)
 	{
 		if ((*service)->isSupported(params) == true)
 		{
@@ -87,10 +151,10 @@ Ice::ObjectProxySeq ServiceLocatorManagementImpl::locateAll(const ServiceLocator
  */
 ServiceManagementPrx ServiceLocatorManagementImpl::addService(const Ice::ObjectPrx& service, const string& guid, const Ice::Current&)
 {
-	boost::unique_lock<boost::shared_mutex> lock(mLock);
-	ServiceManagementImplPtr new_service = new ServiceManagementImpl(this, service, mAdapter, mLocatorTopic, guid);
+	boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
+	ServiceManagementImplPtr new_service = new ServiceManagementImpl(this, service, mImpl->mAdapter, mImpl->mLocatorTopic, guid);
 
-	mServices.push_back(new_service);
+	mImpl->mServices.push_back(new_service);
 
 	return new_service->GetServiceManagementPrx();
 }
@@ -100,18 +164,18 @@ ServiceManagementPrx ServiceLocatorManagementImpl::addService(const Ice::ObjectP
  */
 void ServiceLocatorManagementImpl::addCompare(const string& guid, const ServiceLocatorParamsComparePrx& service, const Ice::Current&)
 {
-	boost::unique_lock<boost::shared_mutex> lock(mLock);
+	boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
 	ServiceLocatorComparator new_comparator(service);
 
 	pair<map<string, ServiceLocatorComparator>::iterator, bool> insert_pair;
-	insert_pair = mCompares.insert(pair<string, ServiceLocatorComparator>(guid, new_comparator));
+	insert_pair = mImpl->mCompares.insert(pair<string, ServiceLocatorComparator>(guid, new_comparator));
 
 	if (insert_pair.second == false)
 	{
 		throw DuplicateCompare();
 	}
 
-	mLocatorTopic->comparisonRegistered(guid);
+	mImpl->mLocatorTopic->comparisonRegistered(guid);
 };
 
 /**
@@ -119,8 +183,8 @@ void ServiceLocatorManagementImpl::addCompare(const string& guid, const ServiceL
  */
 void ServiceLocatorManagementImpl::removeCompare(const string& guid, const Ice::Current&)
 {
-	boost::unique_lock<boost::shared_mutex> lock(mLock);
-	int erased = mCompares.erase(guid);
+	boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
+	int erased = mImpl->mCompares.erase(guid);
 
 	if (!erased)
 	{
@@ -128,7 +192,7 @@ void ServiceLocatorManagementImpl::removeCompare(const string& guid, const Ice::
 	}
 	else
 	{
-		mLocatorTopic->comparisonUnregistered(guid);
+		mImpl->mLocatorTopic->comparisonUnregistered(guid);
 	}
 };
 
@@ -140,9 +204,9 @@ bool ServiceLocatorManagementImpl::isSupported(const string& compare_guid, const
 	/* You'll note there is no lock here. This is because we already have a lock in the locate or locateAll
 	 * functions.
 	 */
-	map<string, ServiceLocatorComparator>::iterator comparator = mCompares.find(compare_guid);
+	map<string, ServiceLocatorComparator>::iterator comparator = mImpl->mCompares.find(compare_guid);
 
-	if (comparator == mCompares.end())
+	if (comparator == mImpl->mCompares.end())
 	{
 		return false;
 	}
@@ -155,12 +219,12 @@ bool ServiceLocatorManagementImpl::isSupported(const string& compare_guid, const
  */
 void ServiceLocatorManagementImpl::removeService(ServiceManagementImplPtr service)
 {
-	boost::unique_lock<boost::shared_mutex> lock(mLock);
-	for (vector<ServiceManagementImplPtr>::iterator existing_service = mServices.begin(); existing_service != mServices.end(); ++existing_service)
+	boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
+	for (vector<ServiceManagementImplPtr>::iterator existing_service = mImpl->mServices.begin(); existing_service != mImpl->mServices.end(); ++existing_service)
 	{
 		if ((*existing_service) == service)
 		{
-			mServices.erase(existing_service);
+			mImpl->mServices.erase(existing_service);
 			return;
 		}
 	}
diff --git a/src/ServiceLocatorManagement.h b/src/ServiceLocatorManagement.h
index a8f9b17..4d6af9a 100644
--- a/src/ServiceLocatorManagement.h
+++ b/src/ServiceLocatorManagement.h
@@ -20,43 +20,22 @@
 #ifndef _SERVICELOCATORMANAGEMENT_H
 #define _SERVICELOCATORMANAGEMENT_H
 
+#include <boost/shared_ptr.hpp>
+
 /**
  * Forward definition for the ServiceManagementImpl class. This gets used by the ServiceLocatorManagementImpl class.
  */
 class ServiceManagementImpl;
 
 /**
- * Small internal class which is used to store information about a comparator.
+ * A typedef which creates a smart pointer type for ServiceManagementImpl.
  */
-class ServiceLocatorComparator
-{
-public:
-	/**
-	 * Constructor for the ServiceLocatorComparator class.
-	 *
-	 * @param compare A proxy to the comparator service we are wrapping.
-	 */
-        ServiceLocatorComparator(const Hydra::System::Location::V1::ServiceLocatorParamsComparePrx& compare) : mCompare(compare) { };
-
-	/**
-	 * API call which forwards an isSupported over ICE to a remote comparator.
-	 *
-	 * @param params Service locator parameters that describe a locator request.
-	 *
-	 * @return A boolean value with true indicating the parameters are supported while false indicates otherwise.
-	 */
-	bool isSupported(const Hydra::System::Location::V1::ServiceLocatorParamsPtr& params) { return mCompare->isSupported(params); };
-private:
-	/**
-	 * A proxy to the comparator service that we are wrapping.
-	 */
-	Hydra::System::Location::V1::ServiceLocatorParamsComparePrx mCompare;
-};
+typedef IceUtil::Handle<ServiceManagementImpl> ServiceManagementImplPtr;
 
 /**
- * A typedef which creates a smart pointer type for ServiceManagementImpl.
+ * Forward definition for our private implementation of ServiceLocatorManagement.
  */
-typedef IceUtil::Handle<ServiceManagementImpl> ServiceManagementImplPtr;
+class ServiceLocatorManagementImplPriv;
 
 /**
  * Implementation of the ServiceLocatorManagement interface as defined in service_locator.ice
@@ -74,31 +53,9 @@ public:
 	void removeService(ServiceManagementImplPtr);
 private:
 	/**
-	 * Shared mutex lock which protects the services and comparators.
-	 */
-	boost::shared_mutex mLock;
-
-	/**
-	 * Object adapter that our service management proxies originate from, it is houses the
-	 * main management service.
-	 */
-	Ice::ObjectAdapterPtr mAdapter;
-
-	/**
-	 * A map of all the comparators that have been added by external components. The key
-	 * is the unique identifier that they add themselves with.
-	 */
-	std::map<std::string, ServiceLocatorComparator> mCompares;
-
-	/**
-	 * A vector of all the services that have been added.
-	 */
-	std::vector<ServiceManagementImplPtr> mServices;
-
-	/**
-	 * A proxy that can be used to publish locator events.
+	 * Private implementation data for ServiceLocatorManagementImpl.
 	 */
-	Hydra::System::Location::EventsPrx mLocatorTopic;
+	boost::shared_ptr<ServiceLocatorManagementImplPriv> mImpl;
 };
 
 #endif
diff --git a/src/ServiceManagement.cpp b/src/ServiceManagement.cpp
index 90777b7..c183f04 100644
--- a/src/ServiceManagement.cpp
+++ b/src/ServiceManagement.cpp
@@ -31,16 +31,120 @@ using namespace Hydra::System::Location;
 using namespace Hydra::System::Location::V1;
 
 /**
+ * Small internal class which is used to store information about supported parameters.
+ */
+class ServiceLocatorParamsSpec {
+public:
+	ServiceLocatorParamsSpec(const Hydra::System::Location::V1::ServiceLocatorParamsPtr& params, const std::string& compare_guid, ServiceLocatorManagementImpl* management)
+		: mParams(params), mCompareGuid(compare_guid), mManagement(management) { };
+	bool isSupported(const Hydra::System::Location::V1::ServiceLocatorParamsPtr&);
+private:
+	/**
+	 * A pointer to a parameters structure which describes what is supported.
+	 */
+	Hydra::System::Location::V1::ServiceLocatorParamsPtr mParams;
+
+	/**
+	 * A string containing the comparator uuid that should be used when comparing the parameters
+	 * in a locator request to this class. If empty no comparator will be used.
+	 */
+	std::string mCompareGuid;
+
+	/**
+	 * A pointer to the service locator management implementation that instantiated this class.
+	 */
+	ServiceLocatorManagementImpl* mManagement;
+};
+
+/**
+ * Small internal class which is used to store private details for ServiceManagementImpl.
+ */
+class ServiceManagementImplPriv
+{
+public:
+	ServiceManagementImplPriv(ServiceManagementImpl* impl, ServiceLocatorManagementImpl* management, const Ice::ObjectPrx& service, Ice::ObjectAdapterPtr adapter,
+				  const EventsPrx& service_discovery_topic, const string& guid) :
+		mSuspended(false), mManagement(management), mService(service), mAdapter(adapter), mLocatorTopic(service_discovery_topic), mGuid(guid)
+		{
+			mManagementPrx = ServiceManagementPrx::uncheckedCast(mAdapter->addWithUUID(impl));
+			mLocatorTopic->serviceRegistered(mGuid);
+		}
+
+        /**
+	 * Shared mutex lock which protects the service.
+	 */
+	boost::shared_mutex mLock;
+
+	/**
+	 * A boolean value which is used to store the suspended state of this service.
+	 */
+	bool mSuspended;
+
+	/**
+	 * A pointer to the service locator management implementation that instantiated this call.
+	 */
+	ServiceLocatorManagementImpl* mManagement;
+
+	/**
+	 * A remote proxy to the service that is registered.
+	 */
+	Ice::ObjectPrx mService;
+
+	/**
+	 * A pointer to the object adapter that this service is available on.
+	 */
+	Ice::ObjectAdapterPtr mAdapter;
+
+	/**
+	 * A local proxy to this management service.
+	 */
+	Hydra::System::Location::V1::ServiceManagementPrx mManagementPrx;
+
+	/**
+	 * A vector of locator parameters that this service supports.
+	 */
+	std::vector<ServiceLocatorParamsSpec> mSupportedLocatorParams;
+
+	/**
+	 * A proxy that can be used to publish events to the service locator topic.
+	 */
+	Hydra::System::Location::EventsPrx mLocatorTopic;
+
+	/**
+	 * A string which contains a unique identifier for this service. This is used
+	 * in events and logging.
+	 */
+	std::string mGuid;
+};
+
+/**
  * Constructor for the ServiceManagementImpl class. This adds itself to the object adapter so the service can perform some management and
  * also sends out an event for those that are listening.
  */
 ServiceManagementImpl::ServiceManagementImpl(ServiceLocatorManagementImpl* management, const Ice::ObjectPrx& service, Ice::ObjectAdapterPtr adapter,
 					     const EventsPrx& service_discovery_topic, const string& guid)
-	: mSuspended(false), mManagement(management), mService(service), mAdapter(adapter), mLocatorTopic(service_discovery_topic), mGuid(guid)
+	: mImpl(new ServiceManagementImplPriv(this, management, service, adapter, service_discovery_topic, guid))
 {
-	mManagementPrx = ServiceManagementPrx::uncheckedCast(mAdapter->addWithUUID(this));
+}
 
-	mLocatorTopic->serviceRegistered(mGuid);
+/**
+ * An internal function which is called to retrieve a proxy to this service.
+ *
+ * @return A proxy to this service.
+ */
+Ice::ObjectPrx ServiceManagementImpl::GetService()
+{
+	return mImpl->mService;
+}
+
+/**
+ * An internal function which is called to retrieve a proxy to the management interface of this service.
+ *
+ * @return A proxy to the management service.
+ */
+ServiceManagementPrx ServiceManagementImpl::GetServiceManagementPrx()
+{
+	return mImpl->mManagementPrx;
 }
 
 /**
@@ -54,15 +158,15 @@ ServiceManagementImpl::ServiceManagementImpl(ServiceLocatorManagementImpl* manag
  */
 bool ServiceManagementImpl::isSupported(const ServiceLocatorParamsPtr& params)
 {
-	boost::shared_lock<boost::shared_mutex> lock(mLock);
+	boost::shared_lock<boost::shared_mutex> lock(mImpl->mLock);
 
 	/* If this service is suspended we can just skip the entire check and return false now, easy as pie */
-	if (mSuspended)
+	if (mImpl->mSuspended)
 	{
 		return false;
 	}
 
-	for (vector<ServiceLocatorParamsSpec>::iterator spec = mSupportedLocatorParams.begin(); spec != mSupportedLocatorParams.end(); ++spec)
+	for (vector<ServiceLocatorParamsSpec>::iterator spec = mImpl->mSupportedLocatorParams.begin(); spec != mImpl->mSupportedLocatorParams.end(); ++spec)
 	{
 		if ((*spec).isSupported(params) == true)
 		{
@@ -104,11 +208,11 @@ bool ServiceLocatorParamsSpec::isSupported(const ServiceLocatorParamsPtr& params
  */
 void ServiceManagementImpl::addLocatorParams(const ServiceLocatorParamsPtr& params, const std::string& compare_guid, const Ice::Current&)
 {
-	boost::unique_lock<boost::shared_mutex> lock(mLock);
+	boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
 
-	ServiceLocatorParamsSpec spec(params, compare_guid, mManagement);
+	ServiceLocatorParamsSpec spec(params, compare_guid, mImpl->mManagement);
 
-	mSupportedLocatorParams.push_back(spec);
+	mImpl->mSupportedLocatorParams.push_back(spec);
 }
 
 /**
@@ -116,11 +220,11 @@ void ServiceManagementImpl::addLocatorParams(const ServiceLocatorParamsPtr& para
  */
 void ServiceManagementImpl::suspend(const Ice::Current&)
 {
-	boost::unique_lock<boost::shared_mutex> lock(mLock);
+	boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
 
-	mSuspended = true;
+	mImpl->mSuspended = true;
 
-	mLocatorTopic->serviceSuspended(mGuid);
+	mImpl->mLocatorTopic->serviceSuspended(mImpl->mGuid);
 }
 
 /**
@@ -128,11 +232,11 @@ void ServiceManagementImpl::suspend(const Ice::Current&)
  */
 void ServiceManagementImpl::unsuspend(const Ice::Current&)
 {
-	boost::unique_lock<boost::shared_mutex> lock(mLock);
+	boost::unique_lock<boost::shared_mutex> lock(mImpl->mLock);
 
-	mSuspended = false;
+	mImpl->mSuspended = false;
 
-	mLocatorTopic->serviceUnsuspended(mGuid);
+	mImpl->mLocatorTopic->serviceUnsuspended(mImpl->mGuid);
 }
 
 /**
@@ -144,11 +248,11 @@ void ServiceManagementImpl::unregister(const Ice::Current&)
 	 * be protected, and if we did lock here there is a chance for a deadlock which is super sad.
 	 */
 
-	mAdapter->remove(mManagementPrx->ice_getIdentity());
+	mImpl->mAdapter->remove(mImpl->mManagementPrx->ice_getIdentity());
 
-	mManagement->removeService(this);
+	mImpl->mManagement->removeService(this);
 
-	mLocatorTopic->serviceUnregistered(mGuid);
+	mImpl->mLocatorTopic->serviceUnregistered(mImpl->mGuid);
 }
 
 
diff --git a/src/ServiceManagement.h b/src/ServiceManagement.h
index f485ab4..5ed468f 100644
--- a/src/ServiceManagement.h
+++ b/src/ServiceManagement.h
@@ -20,31 +20,12 @@
 #ifndef _SERVICEMANAGEMENT_H
 #define _SERVICEMANAGEMENT_H
 
+#include <boost/shared_ptr.hpp>
+
 /**
- * Small internal class which is used to store information about supported parameters.
+ * Forward definition for our private implementation of ServiceLocatorManagement.
  */
-class ServiceLocatorParamsSpec {
-public:
-ServiceLocatorParamsSpec(const Hydra::System::Location::V1::ServiceLocatorParamsPtr& params, const std::string& compare_guid, ServiceLocatorManagementImpl* management)
-		: mParams(params), mCompareGuid(compare_guid), mManagement(management) { };
-	bool isSupported(const Hydra::System::Location::V1::ServiceLocatorParamsPtr&);
-private:
-	/**
-	 * A pointer to a parameters structure which describes what is supported.
-	 */
-	Hydra::System::Location::V1::ServiceLocatorParamsPtr mParams;
-
-	/**
-	 * A string containing the comparator uuid that should be used when comparing the parameters
-	 * in a locator request to this class. If empty no comparator will be used.
-	 */
-	std::string mCompareGuid;
-
-	/**
-	 * A pointer to the service locator management implementation that instantiated this class.
-	 */
-	ServiceLocatorManagementImpl* mManagement;
-};
+class ServiceManagementImplPriv;
 
 /**
  * An implementation of the ServiceManagement interface as defined in service_locator.ice
@@ -57,64 +38,14 @@ public:
 	void suspend(const Ice::Current&);
 	void unsuspend(const Ice::Current&);
 	void unregister(const Ice::Current&);
-
-	/**
-	 * Function which returns the remote proxy to this service.
-	 */
-	Ice::ObjectPrx GetService() { return mService; };
-
-	/**
-	 * Function which returns a local proxy to this service's management interface.
-	 */
-	Hydra::System::Location::V1::ServiceManagementPrx GetServiceManagementPrx() { return mManagementPrx; };
-
+	Ice::ObjectPrx GetService();
+	Hydra::System::Location::V1::ServiceManagementPrx GetServiceManagementPrx();
 	bool isSupported(const Hydra::System::Location::V1::ServiceLocatorParamsPtr&);
 private:
-	/**
-	 * Shared mutex lock which protects the service.
-	 */
-	boost::shared_mutex mLock;
-
-	/**
-	 * A boolean value which is used to store the suspended state of this service.
-	 */
-	bool mSuspended;
-
-	/**
-	 * A pointer to the service locator management implementation that instantiated this call.
-	 */
-	ServiceLocatorManagementImpl* mManagement;
-
-	/**
-	 * A remote proxy to the service that is registered.
-	 */
-	Ice::ObjectPrx mService;
-
-	/**
-	 * A pointer to the object adapter that this service is available on.
-	 */
-	Ice::ObjectAdapterPtr mAdapter;
-
-	/**
-	 * A local proxy to this management service.
-	 */
-	Hydra::System::Location::V1::ServiceManagementPrx mManagementPrx;
-
-	/**
-	 * A vector of locator parameters that this service supports.
-	 */
-	std::vector<ServiceLocatorParamsSpec> mSupportedLocatorParams;
-
-	/**
-	 * A proxy that can be used to publish events to the service locator topic.
-	 */
-	Hydra::System::Location::EventsPrx mLocatorTopic;
-
-	/**
-	 * A string which contains a unique identifier for this service. This is used
-	 * in events and logging.
+        /**
+	 * Private implementation data for ServiceManagementImpl.
 	 */
-	std::string mGuid;
+	boost::shared_ptr<ServiceManagementImplPriv> mImpl;
 };
 
 #endif

commit 01f78763616934ce98bbbf30035f3e39dd87c027
Author: Joshua Colp <jcolp at digium.com>
Date:   Tue Aug 3 19:47:32 2010 -0300

    Per a comment from Ken move the constructor for ServiceLocatorManagementImpl to the source file.

diff --git a/src/ServiceLocatorManagement.cpp b/src/ServiceLocatorManagement.cpp
index 67ec673..73b196f 100644
--- a/src/ServiceLocatorManagement.cpp
+++ b/src/ServiceLocatorManagement.cpp
@@ -31,6 +31,14 @@ using namespace Hydra::System::Location;
 using namespace Hydra::System::Location::V1;
 
 /**
+ * Implementation of a constructor for the ServiceLocatorManagementImpl class.
+ */
+ServiceLocatorManagementImpl::ServiceLocatorManagementImpl(Ice::ObjectAdapterPtr adapter, const Hydra::System::Location::EventsPrx& service_discovery_topic)
+        : mAdapter(adapter), mLocatorTopic(service_discovery_topic)
+{
+}
+
+/**
  * Implementation of the locate method as defined in service_locator.ice
  */
 Ice::ObjectPrx ServiceLocatorManagementImpl::locate(const ServiceLocatorParamsPtr& params)
diff --git a/src/ServiceLocatorManagement.h b/src/ServiceLocatorManagement.h
index 87b7810..a8f9b17 100644
--- a/src/ServiceLocatorManagement.h
+++ b/src/ServiceLocatorManagement.h
@@ -64,8 +64,7 @@ typedef IceUtil::Handle<ServiceManagementImpl> ServiceManagementImplPtr;
 class ServiceLocatorManagementImpl : public Hydra::System::Location::V1::ServiceLocatorManagement
 {
 public:
-ServiceLocatorManagementImpl(Ice::ObjectAdapterPtr adapter, const Hydra::System::Location::EventsPrx& service_discovery_topic)
-	: mAdapter(adapter), mLocatorTopic(service_discovery_topic) { };
+	ServiceLocatorManagementImpl(Ice::ObjectAdapterPtr adapter, const Hydra::System::Location::EventsPrx& service_discovery_topic);
 	Ice::ObjectPrx locate(const Hydra::System::Location::V1::ServiceLocatorParamsPtr&);
 	Ice::ObjectProxySeq locateAll(const Hydra::System::Location::V1::ServiceLocatorParamsPtr&);
 	Hydra::System::Location::V1::ServiceManagementPrx addService(const Ice::ObjectPrx&, const std::string&, const Ice::Current&);

commit f7276bbcac627e39ac97fa9c3fa240a75ee70868
Author: Joshua Colp <jcolp at digium.com>
Date:   Tue Aug 3 19:39:29 2010 -0300

    Fix up braces.

diff --git a/src/ServiceLocator.cpp b/src/ServiceLocator.cpp
index 215255c..e34a33d 100644
--- a/src/ServiceLocator.cpp
+++ b/src/ServiceLocator.cpp
@@ -98,7 +98,8 @@ int ServiceLocatorApp::run(int argc, char* argv[])
 	/* Talk to the topic manager to either create or get the service discovery topic, configured or default */
 	IceStorm::TopicManagerPrx topicManager = IceStorm::TopicManagerPrx::checkedCast(communicator()->propertyToProxy("TopicManager.Proxy"));
 
-	if (!topicManager) {
+	if (!topicManager)
+	{
 		cerr << "Failed to get a proxy to the topic manager." << endl;
 		return 0;
 	}
@@ -106,19 +107,24 @@ int ServiceLocatorApp::run(int argc, char* argv[])
 	Ice::PropertiesPtr props = communicator()->getProperties();
 	string topicName = props->getProperty("ServiceLocator.TopicName");
 
-	if (topicName.empty()) {
+	if (topicName.empty())
+	{
 		topicName = TOPIC;
 	}
 
 	IceStorm::TopicPrx topic;
-	try {
+	try
+	{
 		topic = topicManager->retrieve(topicName);
 	}
-	catch(const IceStorm::NoSuchTopic&) {
-		try {
+	catch (const IceStorm::NoSuchTopic&)
+	{
+		try
+		{
 			topic = topicManager->create(topicName);
 		}
-		catch(const IceStorm::TopicExists&) {
+		catch (const IceStorm::TopicExists&)
+		{
 			cerr << "Oh snap! Race condition creating topic, aborting" << endl;
 			return 0;
 		}
diff --git a/src/ServiceLocatorManagement.cpp b/src/ServiceLocatorManagement.cpp
index b3707d6..67ec673 100644
--- a/src/ServiceLocatorManagement.cpp
+++ b/src/ServiceLocatorManagement.cpp
@@ -37,8 +37,10 @@ Ice::ObjectPrx ServiceLocatorManagementImpl::locate(const ServiceLocatorParamsPt
 {
 	boost::shared_lock<boost::shared_mutex> lock(mLock);
 
-	for (vector<ServiceManagementImplPtr>::iterator service = mServices.begin(); service != mServices.end(); ++service) {
-		if ((*service)->isSupported(params) == true) {
+	for (vector<ServiceManagementImplPtr>::iterator service = mServices.begin(); service != mServices.end(); ++service)
+	{
+		if ((*service)->isSupported(params) == true)
+		{
 			return (*service)->GetService();
 		}
 	}
@@ -54,15 +56,20 @@ Ice::ObjectProxySeq ServiceLocatorManagementImpl::locateAll(const ServiceLocator
 	boost::shared_lock<boost::shared_mutex> lock(mLock);
 	Ice::ObjectProxySeq applicable_services;
 
-	for (vector<ServiceManagementImplPtr>::iterator service = mServices.begin(); service != mServices.end(); ++service) {
-		if ((*service)->isSupported(params) == true) {
+	for (vector<ServiceManagementImplPtr>::iterator service = mServices.begin(); service != mServices.end(); ++service)
+	{
+		if ((*service)->isSupported(params) == true)
+		{
 			applicable_services.push_back((*service)->GetService());
 		}
 	}
 
-	if (!applicable_services.empty()) {
+	if (!applicable_services.empty())
+	{
 		return applicable_services;
-	} else {
+	}
+	else
+	{
 		throw ServiceNotFound();
 	}
 }
@@ -91,7 +98,8 @@ void ServiceLocatorManagementImpl::addCompare(const string& guid, const ServiceL
 	pair<map<string, ServiceLocatorComparator>::iterator, bool> insert_pair;
 	insert_pair = mCompares.insert(pair<string, ServiceLocatorComparator>(guid, new_comparator));
 
-	if (insert_pair.second == false) {
+	if (insert_pair.second == false)
+	{
 		throw DuplicateCompare();
 	}
 
@@ -106,9 +114,12 @@ void ServiceLocatorManagementImpl::removeCompare(const string& guid, const Ice::
 	boost::unique_lock<boost::shared_mutex> lock(mLock);
 	int erased = mCompares.erase(guid);
 
-	if (!erased) {
+	if (!erased)
+	{
 		throw CompareNotFound();
-	} else {
+	}
+	else
+	{
 		mLocatorTopic->comparisonUnregistered(guid);
 	}
 };
@@ -123,7 +134,8 @@ bool ServiceLocatorManagementImpl::isSupported(const string& compare_guid, const
 	 */
 	map<string, ServiceLocatorComparator>::iterator comparator = mCompares.find(compare_guid);
 
-	if (comparator == mCompares.end()) {
+	if (comparator == mCompares.end())
+	{
 		return false;
 	}
 
@@ -136,8 +148,10 @@ bool ServiceLocatorManagementImpl::isSupported(const string& compare_guid, const
 void ServiceLocatorManagementImpl::removeService(ServiceManagementImplPtr service)
 {
 	boost::unique_lock<boost::shared_mutex> lock(mLock);
-	for (vector<ServiceManagementImplPtr>::iterator existing_service = mServices.begin(); existing_service != mServices.end(); ++existing_service) {
-		if ((*existing_service) == service) {
+	for (vector<ServiceManagementImplPtr>::iterator existing_service = mServices.begin(); existing_service != mServices.end(); ++existing_service)
+	{
+		if ((*existing_service) == service)
+		{
 			mServices.erase(existing_service);
 			return;
 		}
diff --git a/src/ServiceManagement.cpp b/src/ServiceManagement.cpp
index 4e9fac7..90777b7 100644
--- a/src/ServiceManagement.cpp
+++ b/src/ServiceManagement.cpp
@@ -57,12 +57,15 @@ bool ServiceManagementImpl::isSupported(const ServiceLocatorParamsPtr& params)
 	boost::shared_lock<boost::shared_mutex> lock(mLock);
 
 	/* If this service is suspended we can just skip the entire check and return false now, easy as pie */
-	if (mSuspended) {
+	if (mSuspended)
+	{
 		return false;
 	}
 
-	for (vector<ServiceLocatorParamsSpec>::iterator spec = mSupportedLocatorParams.begin(); spec != mSupportedLocatorParams.end(); ++spec) {
-		if ((*spec).isSupported(params) == true) {
+	for (vector<ServiceLocatorParamsSpec>::iterator spec = mSupportedLocatorParams.begin(); spec != mSupportedLocatorParams.end(); ++spec)
+	{
+		if ((*spec).isSupported(params) == true)
+		{
 			return true;
 		}
 	}
@@ -82,12 +85,14 @@ bool ServiceManagementImpl::isSupported(const ServiceLocatorParamsPtr& params)
 bool ServiceLocatorParamsSpec::isSupported(const ServiceLocatorParamsPtr& params)
 {
 	/* This is just a simple comparison that acts as a preliminary, and perhaps final, check */
-	if (mParams->category != params->category) {
+	if (mParams->category != params->category)
+	{
 		return false;
 	}
 
 	/* If a comparator was provided then yield to it for a final yay or nay */
-	if (!mCompareGuid.empty()) {
+	if (!mCompareGuid.empty())
+	{
 		return mManagement->isSupported(mCompareGuid, params);
 	}
 

-----------------------------------------------------------------------


-- 
hydra/servicediscovery.git




More information about the asterisk-scf-commits mailing list