#pragma once #include "MCTPDeviceRepository.hpp" #include "MCTPEndpoint.hpp" #include "Utils.hpp" #include #include struct AssociationServer { virtual ~AssociationServer() = default; virtual void associate(const std::string& path, const std::vector& associations) = 0; virtual void disassociate(const std::string& path) = 0; }; class MCTPReactor : public std::enable_shared_from_this { using MCTPDeviceFactory = std::function( const std::string& interface, const std::vector& physaddr, std::optional eid)>; public: MCTPReactor() = delete; MCTPReactor(const MCTPReactor&) = delete; MCTPReactor(MCTPReactor&&) = delete; explicit MCTPReactor(AssociationServer& server) : server(server) {} ~MCTPReactor() = default; MCTPReactor& operator=(const MCTPReactor&) = delete; MCTPReactor& operator=(MCTPReactor&&) = delete; void tick(); void manageMCTPDevice(const std::string& path, const std::shared_ptr& device); void unmanageMCTPDevice(const std::string& path); private: static std::optional findSMBusInterface(int bus); AssociationServer& server; MCTPDeviceRepository devices; // Tracks MCTP devices that have failed their setup std::set> deferred; void deferSetup(const std::shared_ptr& dev); void setupEndpoint(const std::shared_ptr& dev); void trackEndpoint(const std::shared_ptr& ep); void untrackEndpoint(const std::shared_ptr& ep); };