diff options
author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-01-12 16:11:24 -0500 |
---|---|---|
committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-01-12 16:53:38 -0500 |
commit | 7b33777b4c9098bbd6d23ba8ef4e6434622c03d1 (patch) | |
tree | 2c9c795e6aef0a3dde55a309490595cc475bc52c /manager.hpp | |
parent | 1ab880a1a03ff8a59e8490395d2181af180983f3 (diff) | |
download | phosphor-inventory-manager-7b33777b4c9098bbd6d23ba8ef4e6434622c03d1.tar.gz phosphor-inventory-manager-7b33777b4c9098bbd6d23ba8ef4e6434622c03d1.zip |
Run astyle
Change-Id: Iec4802e9837465a7deb1fd7fd57a2068cc18c50d
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'manager.hpp')
-rw-r--r-- | manager.hpp | 314 |
1 files changed, 157 insertions, 157 deletions
diff --git a/manager.hpp b/manager.hpp index 0954953..1c060bc 100644 --- a/manager.hpp +++ b/manager.hpp @@ -35,15 +35,15 @@ using ManagerIface = template <typename T> struct MakeInterface { - static decltype(auto) make(sdbusplus::bus::bus &bus, const char *path) + static decltype(auto) make(sdbusplus::bus::bus& bus, const char* path) { 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))))); + 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))))); } }; } // namespace details @@ -58,159 +58,159 @@ class Manager final : public details::ServerObject<details::ManagerIface> { public: - Manager() = delete; - Manager(const Manager&) = delete; - Manager& operator=(const Manager&) = delete; - Manager(Manager&&) = default; - Manager& operator=(Manager&&) = default; - ~Manager() = default; - - /** @brief Construct an inventory manager. - * - * @param[in] bus - An sdbusplus bus connection. - * @param[in] busname - The DBus busname to own. - * @param[in] root - The DBus path on which to implement - * an inventory manager. - * @param[in] iface - The DBus inventory interface to implement. - */ - Manager(sdbusplus::bus::bus &&, const char *, const char*, const char*); - - using Object = std::map< - std::string, std::map< - std::string, sdbusplus::message::variant<std::string>>>; - using EventInfo = std::tuple< - std::vector<details::EventBasePtr>, - std::vector<details::ActionBasePtr>>; - - /** @brief Start processing DBus messages. */ - void run() noexcept; - - /** @brief Provided for testing only. */ - void shutdown() noexcept; - - /** @brief sd_bus Notify method implementation callback. */ - void notify(std::string path, Object) override; - - /** @brief sd_bus signal callback. */ - void signal(sdbusplus::message::message&, - const details::DbusSignal &event, - const EventInfo &info); - - /** @brief Drop an object from DBus. */ - void destroyObject(const char *); - - /** @brief Invoke an sdbusplus server binding method. - * - * Invoke the requested method with a reference to the requested - * sdbusplus server binding interface as a parameter. - * - * @tparam T - The sdbusplus server binding interface type. - * @tparam U - The type of the sdbusplus server binding member. - * @tparam Args - Argument types of the binding member. - * - * @param[in] path - The DBus path on which the method should - * be invoked. - * @param[in] interface - The DBus interface hosting the method. - * @param[in] member - Pointer to sdbusplus server binding member. - * @param[in] args - Arguments to forward to the binding member. - * - * @returns - The return/value type of the binding method being - * called. - */ - template<typename T, typename U, typename ...Args> - decltype(auto) invokeMethod(const char *path, const char *interface, - U&& member, Args&&...args) - { - auto &holder = getInterface<std::unique_ptr<T>>(path, interface); - auto &iface = *holder.get(); - return (iface.*member)(std::forward<Args>(args)...); - } - - using SigArgs = std::vector< - std::unique_ptr< - std::tuple< - Manager *, - const details::DbusSignal *, - const EventInfo *>>>; - using SigArg = SigArgs::value_type::element_type; + Manager() = delete; + Manager(const Manager&) = delete; + Manager& operator=(const Manager&) = delete; + Manager(Manager&&) = default; + Manager& operator=(Manager&&) = default; + ~Manager() = default; + + /** @brief Construct an inventory manager. + * + * @param[in] bus - An sdbusplus bus connection. + * @param[in] busname - The DBus busname to own. + * @param[in] root - The DBus path on which to implement + * an inventory manager. + * @param[in] iface - The DBus inventory interface to implement. + */ + Manager(sdbusplus::bus::bus&&, const char*, const char*, const char*); + + using Object = std::map < + std::string, std::map < + std::string, sdbusplus::message::variant<std::string >>>; + using EventInfo = std::tuple < + std::vector<details::EventBasePtr>, + std::vector<details::ActionBasePtr >>; + + /** @brief Start processing DBus messages. */ + void run() noexcept; + + /** @brief Provided for testing only. */ + void shutdown() noexcept; + + /** @brief sd_bus Notify method implementation callback. */ + void notify(std::string path, Object) override; + + /** @brief sd_bus signal callback. */ + void signal(sdbusplus::message::message&, + const details::DbusSignal& event, + const EventInfo& info); + + /** @brief Drop an object from DBus. */ + void destroyObject(const char*); + + /** @brief Invoke an sdbusplus server binding method. + * + * Invoke the requested method with a reference to the requested + * sdbusplus server binding interface as a parameter. + * + * @tparam T - The sdbusplus server binding interface type. + * @tparam U - The type of the sdbusplus server binding member. + * @tparam Args - Argument types of the binding member. + * + * @param[in] path - The DBus path on which the method should + * be invoked. + * @param[in] interface - The DBus interface hosting the method. + * @param[in] member - Pointer to sdbusplus server binding member. + * @param[in] args - Arguments to forward to the binding member. + * + * @returns - The return/value type of the binding method being + * called. + */ + template<typename T, typename U, typename ...Args> + decltype(auto) invokeMethod(const char* path, const char* interface, + U&& member, Args&& ...args) + { + auto& holder = getInterface<std::unique_ptr<T>>(path, interface); + auto& iface = *holder.get(); + return (iface.*member)(std::forward<Args>(args)...); + } + + using SigArgs = std::vector < + std::unique_ptr < + std::tuple < + Manager*, + const details::DbusSignal*, + const EventInfo* >>>; + using SigArg = SigArgs::value_type::element_type; private: - using HolderPtr = std::unique_ptr<details::holder::Base>; - 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 *); - using Makers = std::map<std::string, MakerType>; - - /** @brief Provides weak references to interface holders. - * - * Common code for all types for the templated getInterface - * methods. - * - * @param[in] path - The DBus path for which the interface - * holder instance should be provided. - * @param[in] interface - The DBus interface for which the - * holder instance should be provided. - * - * @returns A weak reference to the holder instance. - */ - details::holder::Base& getInterfaceHolder( - const char *, const char *) const; - details::holder::Base& getInterfaceHolder( - const char *, const char *); - - /** @brief Provides weak references to interface holders. - * - * @tparam T - The sdbusplus server binding interface type. - * - * @param[in] path - The DBus path for which the interface - * should be provided. - * @param[in] interface - The DBus interface to obtain. - * - * @returns A weak reference to the interface holder. - */ - template<typename T> - auto& getInterface(const char *path, const char *interface) - { - auto &holder = getInterfaceHolder(path, interface); - return static_cast< - details::holder::Holder<T> &>(holder); - } - template<typename T> - auto& getInterface(const char *path, const char *interface) const - { - auto &holder = getInterfaceHolder(path, interface); - return static_cast< - const details::holder::Holder<T> &>(holder); - } - - /** @brief Provided for testing only. */ - bool _shutdown; - - /** @brief Path prefix applied to any relative paths. */ - const char * _root; - - /** @brief A container of sdbusplus server interface references. */ - ObjectReferences _refs; - - /** @brief A container contexts for signal callbacks. */ - SigArgs _sigargs; - - /** @brief A container of sdbusplus signal matches. */ - std::vector<sdbusplus::server::match::match> _matches; - - /** @brief Persistent sdbusplus DBus bus connection. */ - sdbusplus::bus::bus _bus; - - /** @brief sdbusplus org.freedesktop.DBus.ObjectManager reference. */ - sdbusplus::server::manager::manager _manager; - - /** @brief A container of pimgen generated events and responses. */ - static const Events _events; - - /** @brief A container of pimgen generated factory methods. */ - static const Makers _makers; + using HolderPtr = std::unique_ptr<details::holder::Base>; + 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*); + using Makers = std::map<std::string, MakerType>; + + /** @brief Provides weak references to interface holders. + * + * Common code for all types for the templated getInterface + * methods. + * + * @param[in] path - The DBus path for which the interface + * holder instance should be provided. + * @param[in] interface - The DBus interface for which the + * holder instance should be provided. + * + * @returns A weak reference to the holder instance. + */ + details::holder::Base& getInterfaceHolder( + const char*, const char*) const; + details::holder::Base& getInterfaceHolder( + const char*, const char*); + + /** @brief Provides weak references to interface holders. + * + * @tparam T - The sdbusplus server binding interface type. + * + * @param[in] path - The DBus path for which the interface + * should be provided. + * @param[in] interface - The DBus interface to obtain. + * + * @returns A weak reference to the interface holder. + */ + template<typename T> + auto& getInterface(const char* path, const char* interface) + { + auto& holder = getInterfaceHolder(path, interface); + return static_cast < + details::holder::Holder<T>& >(holder); + } + template<typename T> + auto& getInterface(const char* path, const char* interface) const + { + auto& holder = getInterfaceHolder(path, interface); + return static_cast < + const details::holder::Holder<T>& >(holder); + } + + /** @brief Provided for testing only. */ + bool _shutdown; + + /** @brief Path prefix applied to any relative paths. */ + const char* _root; + + /** @brief A container of sdbusplus server interface references. */ + ObjectReferences _refs; + + /** @brief A container contexts for signal callbacks. */ + SigArgs _sigargs; + + /** @brief A container of sdbusplus signal matches. */ + std::vector<sdbusplus::server::match::match> _matches; + + /** @brief Persistent sdbusplus DBus bus connection. */ + sdbusplus::bus::bus _bus; + + /** @brief sdbusplus org.freedesktop.DBus.ObjectManager reference. */ + sdbusplus::server::manager::manager _manager; + + /** @brief A container of pimgen generated events and responses. */ + static const Events _events; + + /** @brief A container of pimgen generated factory methods. */ + static const Makers _makers; }; } // namespace manager |