summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad Bishop <bradleyb@fuzziesquirrel.com>2017-01-22 01:03:02 -0500
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2017-02-01 16:13:11 -0500
commit1157af1bd44655b34b10c1308cacaa7c1acb4b38 (patch)
tree47f7bc07f218be5eacb0a107f1d00eab4be18458
parent48547a85412bcb5c6430978ce58fb96a96234293 (diff)
downloadphosphor-inventory-manager-1157af1bd44655b34b10c1308cacaa7c1acb4b38.tar.gz
phosphor-inventory-manager-1157af1bd44655b34b10c1308cacaa7c1acb4b38.zip
Remove Object from testcase
Currently the testcase and the application both define their own Object type. Move to a common header. Change-Id: I05dba67dca7855f522be299fcfd361913ed73fbc Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
-rw-r--r--manager.hpp4
-rw-r--r--test/test.cpp25
-rw-r--r--types.hpp30
3 files changed, 40 insertions, 19 deletions
diff --git a/manager.hpp b/manager.hpp
index 616e45d..33980b9 100644
--- a/manager.hpp
+++ b/manager.hpp
@@ -8,6 +8,7 @@
#include "xyz/openbmc_project/Inventory/Manager/server.hpp"
#include "events.hpp"
#include "actions.hpp"
+#include "types.hpp"
namespace phosphor
{
@@ -76,9 +77,6 @@ class Manager final :
*/
Manager(sdbusplus::bus::bus&&, const char*, const char*, const char*);
- using Object = std::map <
- std::string, std::map <
- std::string, sdbusplus::message::variant<int64_t, std::string >>>;
using EventInfo = std::tuple <
std::vector<details::EventBasePtr>,
std::vector<details::ActionBasePtr >>;
diff --git a/test/test.cpp b/test/test.cpp
index e4b6a45..21f89e2 100644
--- a/test/test.cpp
+++ b/test/test.cpp
@@ -91,6 +91,8 @@ struct ExampleService
sdbusplus::server::manager::manager objmgr;
};
+using Object = phosphor::inventory::manager::Object;
+
/** @class SignalQueue
* @brief Store DBus signals in a queue.
*/
@@ -136,18 +138,10 @@ class SignalQueue
sdbusplus::message::message _next;
};
-template <typename ...T>
-using Object = std::map <
- std::string,
- std::map <
- std::string,
- sdbusplus::message::variant<T... >>>;
-
/**@brief Find a subset of interfaces and properties in an object. */
-template <typename ...T>
-auto hasProperties(const Object<T...>& l, const Object<T...>& r)
+auto hasProperties(const Object& l, const Object& r)
{
- Object<T...> result;
+ Object result;
std::set_difference(
r.cbegin(),
r.cend(),
@@ -158,8 +152,7 @@ auto hasProperties(const Object<T...>& l, const Object<T...>& r)
}
/**@brief Check an object for one or more interfaces. */
-template <typename ...T>
-auto hasInterfaces(const std::vector<std::string>& l, const Object<T...>& r)
+auto hasInterfaces(const std::vector<std::string>& l, const Object& r)
{
std::vector<std::string> stripped, interfaces;
std::transform(
@@ -201,7 +194,7 @@ void runTests()
"Set");
};
- Object<std::string> obj
+ Object obj
{
{
"xyz.openbmc_project.Example.Iface1",
@@ -229,11 +222,11 @@ void runTests()
auto sig{queue.pop()};
assert(sig);
sdbusplus::message::object_path signalPath;
- Object<std::string> signalObject;
+ Object signalObjectType;
sig.read(signalPath);
assert(path == signalPath.str);
- sig.read(signalObject);
- assert(hasProperties(signalObject, obj));
+ sig.read(signalObjectType);
+ assert(hasProperties(signalObjectType, obj));
auto moreSignals{queue.pop()};
assert(!moreSignals);
}
diff --git a/types.hpp b/types.hpp
new file mode 100644
index 0000000..3643bb1
--- /dev/null
+++ b/types.hpp
@@ -0,0 +1,30 @@
+#pragma once
+
+#include <map>
+#include <string>
+#include <sdbusplus/message.hpp>
+
+namespace phosphor
+{
+namespace inventory
+{
+namespace manager
+{
+
+/** @brief Inventory manager supported property types. */
+using InterfaceVariantType = sdbusplus::message::variant<int64_t, std::string>;
+
+template <typename T>
+using InterfaceType = std::map<std::string, T>;
+
+template <typename T>
+using ObjectType = std::map<std::string, InterfaceType<T>>;
+
+using Interface = InterfaceType<InterfaceVariantType>;
+using Object = ObjectType<InterfaceVariantType>;
+
+} // namespace manager
+} // namespace inventory
+} // namespace phosphor
+
+// vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
OpenPOWER on IntegriCloud