diff options
author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-01-22 16:40:47 -0500 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-02-01 16:17:42 -0500 |
commit | 90c30bc515bfe0d16da44c723a5d91f72a4d1a41 (patch) | |
tree | d0f2b20bdf91dff0b7177a690178829936977e25 /manager.hpp | |
parent | 1157af1bd44655b34b10c1308cacaa7c1acb4b38 (diff) | |
download | phosphor-inventory-manager-90c30bc515bfe0d16da44c723a5d91f72a4d1a41.tar.gz phosphor-inventory-manager-90c30bc515bfe0d16da44c723a5d91f72a4d1a41.zip |
Maker factory refactoring
Prepare for the addition of new iface -> class op adapters.
Get ready to pass the interface properties to the sdbusplus
server binding constructor, once that method is available.
Change-Id: I002cc187ac3d8d8a7fd02cc820f831e345e49a61
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'manager.hpp')
-rw-r--r-- | manager.hpp | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/manager.hpp b/manager.hpp index 33980b9..7a01bee 100644 --- a/manager.hpp +++ b/manager.hpp @@ -36,16 +36,20 @@ using ManagerIface = template <typename T> struct MakeInterface { - static auto make(sdbusplus::bus::bus& bus, const char* path, bool deferSignals) + static std::unique_ptr<details::holder::Base> make( + sdbusplus::bus::bus& bus, + const char* path, + const Interface& props, + bool deferSignals) { + // TODO: pass props to import constructor... using HolderType = holder::Holder<std::unique_ptr<T>>; - return static_cast<std::unique_ptr<holder::Base>>( - HolderType::template make_unique<HolderType>( - std::forward<std::unique_ptr<T>>( - std::make_unique<T>( - std::forward<decltype(bus)>(bus), - std::forward<decltype(path)>(path), - std::forward<decltype(deferSignals)>(deferSignals))))); + return HolderType::template make_unique<HolderType>( + std::forward<std::unique_ptr<T>>( + std::make_unique<T>( + std::forward<decltype(bus)>(bus), + std::forward<decltype(path)>(path), + std::forward<decltype(deferSignals)>(deferSignals)))); } }; } // namespace details @@ -139,9 +143,12 @@ class Manager final : using InterfaceComposite = std::map<std::string, HolderPtr>; using ObjectReferences = std::map<std::string, InterfaceComposite>; using Events = std::vector<EventInfo>; - using MakerType = HolderPtr(*)( - sdbusplus::bus::bus&, const char*, bool); - using Makers = std::map<std::string, MakerType>; + + // The int instantiation is safe since the signature of these + // functions don't change from one instantiation to the next. + using MakerType = std::add_pointer_t < + decltype(details::MakeInterface<int>::make) >; + using Makers = std::map<std::string, std::tuple<MakerType>>; /** @brief Provides weak references to interface holders. * |