X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/bc6cac0e474dfe2feb4983aef98f99e23a98ffc4..ee1709cd231588fe672d0bd2546ef69ee87ff88c:/projects/stargazer/plugins/other/smux/smux.h diff --git a/projects/stargazer/plugins/other/smux/smux.h b/projects/stargazer/plugins/other/smux/smux.h index f45beffc..1986d28b 100644 --- a/projects/stargazer/plugins/other/smux/smux.h +++ b/projects/stargazer/plugins/other/smux/smux.h @@ -1,28 +1,28 @@ -#ifndef __SMUX_H__ -#define __SMUX_H__ +#pragma once -#include -#include -#include -#include -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wshadow" -#include -#pragma GCC diagnostic pop -#include +#include "sensors.h" +#include "tables.h" +#include "types.h" #include "stg/SMUX-PDUs.h" #include "stg/ObjectSyntax.h" #include "stg/plugin.h" #include "stg/module_settings.h" +#include "stg/subscriptions.h" #include "stg/notifer.h" #include "stg/noncopyable.h" #include "stg/logger.h" -#include "sensors.h" -#include "tables.h" -#include "types.h" +#include +#include +#include +#include +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wshadow" +#include +#pragma GCC diagnostic pop +#include namespace STG { @@ -87,24 +87,6 @@ public: : STG::NotifierBase(), smux(s) {} void notify(const STG::TariffData &) override; -private: - SMUX & smux; -}; -//----------------------------------------------------------------------------- -class ADD_USER_NOTIFIER : public STG::NotifierBase { -public: - explicit ADD_USER_NOTIFIER(SMUX & s) : STG::NotifierBase(), smux(s) {} - void notify(const UserPtr &) override; - -private: - SMUX & smux; -}; -//----------------------------------------------------------------------------- -class DEL_USER_NOTIFIER : public STG::NotifierBase { -public: - explicit DEL_USER_NOTIFIER(SMUX & s) : STG::NotifierBase(), smux(s) {} - void notify(const UserPtr &) override; - private: SMUX & smux; }; @@ -186,9 +168,10 @@ private: Sensors sensors; Tables tables; + STG::ScopedConnection m_onAddUserConn; + STG::ScopedConnection m_onDelUserConn; + std::list notifiers; - ADD_USER_NOTIFIER addUserNotifier; - DEL_USER_NOTIFIER delUserNotifier; ADD_DEL_TARIFF_NOTIFIER addDelTariffNotifier; STG::PluginLogger logger; @@ -206,19 +189,3 @@ void ADD_DEL_TARIFF_NOTIFIER::notify(const STG::TariffData &) { smux.UpdateTables(); } - -inline -void ADD_USER_NOTIFIER::notify(const UserPtr & userPtr) -{ -smux.SetNotifier(userPtr); -smux.UpdateTables(); -} - -inline -void DEL_USER_NOTIFIER::notify(const UserPtr & userPtr) -{ -smux.UnsetNotifier(userPtr); -smux.UpdateTables(); -} - -#endif