summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2018-09-18 16:13:25 -0500
committerMatt Spinler <spinler@us.ibm.com>2018-09-28 08:24:53 -0500
commit7a38d419b47df49543a6fc29beb3279d311596d3 (patch)
tree1850b7b61b88d8f3a73e75d476b088110b5385a2
parent9f0958e18c3ba36f6ec8e58101654d69e4e34799 (diff)
downloadphosphor-objmgr-7a38d419b47df49543a6fc29beb3279d311596d3.tar.gz
phosphor-objmgr-7a38d419b47df49543a6fc29beb3279d311596d3.zip
Filter results of GetObject
GetObject should only return the services (with their interfaces) that provide the interface passed in. Change-Id: I76ca7be85c7f2da4cc66d865a671c27504cb8061 Signed-off-by: Matt Spinler <spinler@us.ibm.com>
-rw-r--r--src/main.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/main.cpp b/src/main.cpp
index a1e6be8..b1fbcbf 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -777,6 +777,10 @@ int main(int argc, char** argv)
iface->register_method(
"GetObject", [&interface_map](const std::string& path,
std::vector<std::string>& interfaces) {
+ boost::container::flat_map<std::string,
+ boost::container::flat_set<std::string>>
+ results;
+
// Interfaces need to be sorted for intersect to function
std::sort(interfaces.begin(), interfaces.end());
auto path_ref = interface_map.find(path);
@@ -794,12 +798,16 @@ int main(int argc, char** argv)
interface_map.second.begin(),
interface_map.second.end()))
{
- return path_ref->second;
+ results.emplace(interface_map.first, interface_map.second);
}
}
- // Unable to find intersection, return default constructed
- // object
- throw NotFoundException();
+
+ if (results.empty())
+ {
+ throw NotFoundException();
+ }
+
+ return results;
});
iface->register_method(
OpenPOWER on IntegriCloud