[asterisk-scf-commits] asterisk-scf/integration/servicediscovery.git branch "locate-with-id" created.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Tue Jun 21 11:56:16 CDT 2011
branch "locate-with-id" has been created
at ae9bde043071e5067ced90d0b11ae157904b26c1 (commit)
- Log -----------------------------------------------------------------
commit ae9bde043071e5067ced90d0b11ae157904b26c1
Author: Ken Hunt <ken.hunt at digium.com>
Date: Tue Jun 21 11:45:58 2011 -0500
Added id test to built-in compare functionality.
diff --git a/src/ServiceLocatorManagement.cpp b/src/ServiceLocatorManagement.cpp
index b1cfe2a..868c932 100644
--- a/src/ServiceLocatorManagement.cpp
+++ b/src/ServiceLocatorManagement.cpp
@@ -372,7 +372,7 @@ ServiceLocatorManagementImpl::ServiceLocatorManagementImpl(
void ServiceLocatorManagementImpl::locate(const AMD_ServiceLocator_locatePtr& cb,
const ServiceLocatorParamsPtr& params)
{
- lg(Debug) << "locate(" << params->category << ')';
+ lg(Debug) << "locate(" << params->category << ", " << params->id << ")";
boost::shared_lock<boost::shared_mutex> lock(mImpl->mLock);
LocateCollectorPtr collector = new LocateOneCollector(cb,
@@ -392,7 +392,7 @@ void ServiceLocatorManagementImpl::locateAll(
const AMD_ServiceLocator_locateAllPtr& cb,
const ServiceLocatorParamsPtr& params)
{
- lg(Debug) << "locateAll(" << params->category << ')';
+ lg(Debug) << "locateAll(" << params->category << ", " << params->id << ")";
boost::shared_lock<boost::shared_mutex> lock(mImpl->mLock);
LocateCollectorPtr collector = new LocateAllCollector(cb,
diff --git a/src/ServiceManagement.cpp b/src/ServiceManagement.cpp
index 3406157..c8e75fe 100644
--- a/src/ServiceManagement.cpp
+++ b/src/ServiceManagement.cpp
@@ -247,7 +247,7 @@ void ServiceManagementImpl::isSupported(const ServiceLocatorParamsPtr& params, c
*/
if (mImpl->mStateItem->suspended)
{
- lg(Debug) << " ...isSupported(" << params->category << ") = false (suspended)\n";
+ lg(Debug) << " ...isSupported(" << params->category << ", " << params->id << ") = false (suspended)\n";
callback->result(false);
return;
}
@@ -285,24 +285,37 @@ void ServiceLocatorParamsSpec::isSupported(const ServiceLocatorParamsPtr& params
{
lg(Debug) << " ...isSupported(" << params->category << ") = true (empty category)\n";
callback->result(true);
+ return;
}
- /* This is just a simple comparison that acts as a preliminary, and
- * perhaps final, check */
- else if (mStateItem->params->category != params->category)
+
+ // Is this the wrong category?
+ if (mStateItem->params->category != params->category)
{
lg(Debug) << " ...isSupported(" << params->category << ") = false (different categories)\n";
callback->result(false);
+ return;
}
- /* If a comparator was provided then yield to it for a final yay or nay */
- else if (!mStateItem->compareGuid.empty())
+
+ // Is query for a specific instance?
+ if (!params->id.empty())
{
- mManagement->isSupported(mStateItem->compareGuid, params, callback);
+ // Wrong instance?
+ if (mStateItem->params->id != params->id)
+ {
+ callback->result(false);
+ return;
+ }
}
- /* category matches, no comparator to turn us down. it's a match. */
- else
+
+ // If a comparator was provided then yield to it for a final yay or nay
+ if (!mStateItem->compareGuid.empty())
{
- callback->result(true);
+ mManagement->isSupported(mStateItem->compareGuid, params, callback);
+ return;
}
+
+ // If we get here we have a match.
+ callback->result(true);
}
/**
-----------------------------------------------------------------------
--
asterisk-scf/integration/servicediscovery.git
More information about the asterisk-scf-commits
mailing list