#pragma once #include "device.hpp" #include "sdbusplus/async/match.hpp" #include #include #include #include #include #include #include using namespace phosphor::software::config; using namespace phosphor::software::device; namespace phosphor::software::manager { // This is the base class for the code updater // Every code updater can inherit from this class SoftwareManager { public: SoftwareManager(sdbusplus::async::context& ctx, const std::string& serviceNameSuffix); // Fetches initial configuration from dbus and initializes devices. // This should be called once by a code updater at startup. // @param configurationInterfaces the dbus interfaces from which to fetch // configuration sdbusplus::async::task<> initDevices( const std::vector& configurationInterfaces); // Map of EM config object path to device. std::map> devices; protected: // This function receives a dbus name and object path for a single device, // which was configured. // The component code updater overrides this function and may create a // device instance internally, or reject the configuration as invalid. // @param service The dbus name where our configuration is // @param config The common configuration properties which are shared // by all devices. // Also includes the object path to fetch other // configuration properties. // @returns true if the configuration was accepted virtual sdbusplus::async::task initDevice(const std::string& service, const std::string& path, SoftwareConfig& config) = 0; std::string getBusName(); sdbusplus::async::context& ctx; private: sdbusplus::async::task handleInterfaceAdded( const std::string& service, const std::string& path, const std::string& interface); sdbusplus::async::task handleInterfaceRemoved( const sdbusplus::message::object_path& path); sdbusplus::async::task interfaceAddedMatch( std::vector interfaces); sdbusplus::async::task interfaceRemovedMatch( std::vector interfaces); // DBus matches for interfaces added and interfaces removed sdbusplus::async::match configIntfAddedMatch; sdbusplus::async::match configIntfRemovedMatch; // the dbus name const std::string serviceName; sdbusplus::server::manager_t manager; friend Software; friend Device; }; }; // namespace phosphor::software::manager