#pragma once #include #include std::vector> requestMuxGPIOs( const std::vector& gpioLines, const std::vector& gpioPolarities, bool inverted); /* * @class GPIOGroup * @brief A group of GPIO lines to be muxed together */ class GPIOGroup { public: GPIOGroup(std::vector lines, std::vector polarities); ~GPIOGroup(); // GPIOs set to route mux to the BMC bool muxToBMC(); // GPIOs set to the opposite values to route mux to the external device bool muxToDevice(); void releaseAll(); GPIOGroup(const GPIOGroup&) = delete; GPIOGroup& operator=(const GPIOGroup&) = delete; GPIOGroup(GPIOGroup&& /*other*/) noexcept; GPIOGroup& operator=(GPIOGroup&& /*other*/) noexcept; private: bool mux(bool inverted); std::vector lines; std::vector polarities; std::vector> activeBulks; }; /* * @class ScopedBmcMux * @brief A RAII wrapper to mux GPIO lines to BMC on construction * and back to device on destruction */ class ScopedBmcMux { public: explicit ScopedBmcMux(GPIOGroup& group); ~ScopedBmcMux(); ScopedBmcMux(const ScopedBmcMux&) = delete; ScopedBmcMux& operator=(const ScopedBmcMux&) = delete; ScopedBmcMux(ScopedBmcMux&& /*other*/) = delete; ScopedBmcMux& operator=(ScopedBmcMux&& /*other*/) = delete; private: GPIOGroup& gpioGroup; };