/* BROKER MODULE Copyright (C) 2017-2019 by Xose PĂ©rez */ #pragma once #include "espurna.h" #include #include #include enum class TBrokerType { System, Status, SensorRead, SensorReport, Datetime, Config }; template using TBrokerCallback = std::function; template using TBrokerCallbacks = std::vector>; template struct TBroker { static TBrokerCallbacks callbacks; static void Register(TBrokerCallback callback) { callbacks.push_back(callback); } static void Publish(TArgs... args) { for (auto& callback : callbacks) { callback(args...); } } }; template TBrokerCallbacks TBroker::callbacks; using StatusBroker = TBroker; using SensorReadBroker = TBroker; using SensorReportBroker = TBroker; using ConfigBroker = TBroker;