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>
diff --git a/manager.hpp b/manager.hpp
index 33980b9..7a01bee 100644
--- a/manager.hpp
+++ b/manager.hpp
@@ -36,16 +36,20 @@
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 @@
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.
*