X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/a500fb72810060e52d87ad2c2e4691531f0bcc5a..1cd2b12bd4e4d86f6cd099240795f3ebeb3852b3:/projects/stargazer/plugins/other/smux/smux.h?ds=sidebyside diff --git a/projects/stargazer/plugins/other/smux/smux.h b/projects/stargazer/plugins/other/smux/smux.h index 80867904..3e708e2b 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 { @@ -71,7 +71,7 @@ public: CHG_AFTER_NOTIFIER(const CHG_AFTER_NOTIFIER & rvalue) : STG::PropertyNotifierBase(), smux(rvalue.smux), userPtr(rvalue.userPtr) {} - void Notify(const std::string &, const std::string &); + void notify(const std::string &, const std::string &) override; UserPtr GetUserPtr() const { return userPtr; } @@ -81,34 +81,6 @@ private: UserPtr userPtr; }; //----------------------------------------------------------------------------- -class ADD_DEL_TARIFF_NOTIFIER : public STG::NotifierBase { -public: - explicit ADD_DEL_TARIFF_NOTIFIER(SMUX & s) - : STG::NotifierBase(), smux(s) {} - void Notify(const STG::TariffData &); - -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 &); - -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 &); - -private: - SMUX & smux; -}; -//----------------------------------------------------------------------------- class SMUX : public STG::Plugin { public: SMUX(); @@ -186,39 +158,19 @@ private: Sensors sensors; Tables tables; + STG::ScopedConnection m_onAddUserConn; + STG::ScopedConnection m_onDelUserConn; + STG::ScopedConnection m_onAddTariffConn; + STG::ScopedConnection m_onDelTariffConn; + std::list notifiers; - ADD_USER_NOTIFIER addUserNotifier; - DEL_USER_NOTIFIER delUserNotifier; - ADD_DEL_TARIFF_NOTIFIER addDelTariffNotifier; STG::PluginLogger logger; }; //----------------------------------------------------------------------------- inline -void CHG_AFTER_NOTIFIER::Notify(const std::string &, const std::string &) +void CHG_AFTER_NOTIFIER::notify(const std::string &, const std::string &) { smux.UpdateTables(); } - -inline -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