X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/32248221316271f3a09a771ce35b77236f4bbeed..b2b89723a2427bba8290bd6967a1ab39cbb630be:/include/stg/tariffs.h?ds=sidebyside diff --git a/include/stg/tariffs.h b/include/stg/tariffs.h index b492833b..959c6112 100644 --- a/include/stg/tariffs.h +++ b/include/stg/tariffs.h @@ -18,30 +18,46 @@ * Author : Maxim Mamontov */ -#ifndef TARIFFS_H -#define TARIFFS_H +#pragma once + +#include "subscriptions.h" #include -#include +#include + +namespace STG +{ + +class Admin; +struct Tariff; +struct TariffData; + +class Tariffs +{ + public: + virtual ~Tariffs() = default; + + virtual int ReadTariffs() = 0; + virtual const Tariff* FindByName(const std::string& name) const = 0; + virtual const Tariff* GetNoTariff() const = 0; + virtual int Del(const std::string& name, const Admin* admin) = 0; + virtual int Add(const std::string& name, const Admin* admin) = 0; + virtual int Chg(const TariffData& td, const Admin* admin) = 0; -class ADMIN; -class TARIFF; -struct TARIFF_DATA; + template + auto onAdd(F&& f) { return m_onAddCallbacks.add(std::forward(f)); } + template + auto onDel(F&& f) { return m_onDelCallbacks.add(std::forward(f)); } -class TARIFFS { -public: - virtual int ReadTariffs () = 0; - virtual const TARIFF * FindByName(const std::string & name) const = 0; - virtual const TARIFF * GetNoTariff() const = 0; - virtual int Del(const std::string & name, const ADMIN * admin) = 0; - virtual int Add(const std::string & name, const ADMIN * admin) = 0; - virtual int Chg(const TARIFF_DATA & td, const ADMIN * admin) = 0; + virtual void GetTariffsData(std::vector* tdl) const = 0; - virtual void GetTariffsData(std::list * tdl) = 0; + virtual size_t Count() const = 0; - virtual size_t Count() const = 0; + virtual const std::string& GetStrError() const = 0; - virtual const std::string & GetStrError() const = 0; + protected: + Subscriptions m_onAddCallbacks; + Subscriptions m_onDelCallbacks; }; -#endif +}