#define TARIFFS_H
#include <string>
-#include <list>
+#include <vector>
#include "notifer.h"
class TARIFFS {
public:
- typedef std::list<TARIFF> Tariffs;
-
virtual ~TARIFFS() {}
virtual int ReadTariffs () = 0;
virtual const TARIFF * FindByName(const std::string & name) const = 0;
virtual void AddNotifierDel(NOTIFIER_BASE<TARIFF_DATA> * notifier) = 0;
virtual void DelNotifierDel(NOTIFIER_BASE<TARIFF_DATA> * notifier) = 0;
- virtual void GetTariffsData(std::list<TARIFF_DATA> * tdl) const = 0;
+ virtual void GetTariffsData(std::vector<TARIFF_DATA> * tdl) const = 0;
virtual size_t Count() const = 0;
return &noTariff;
STG_LOCKER lock(&mutex);
-std::list<TARIFF_IMPL>::const_iterator ti;
-ti = find(tariffs.begin(), tariffs.end(), TARIFF_IMPL(name));
+const auto ti = find(tariffs.begin(), tariffs.end(), TARIFF_IMPL(name));
if (ti != tariffs.end())
return &(*ti);
STG_LOCKER lock(&mutex);
-std::list<TARIFF_IMPL>::iterator ti;
-ti = find(tariffs.begin(), tariffs.end(), TARIFF_IMPL(td.tariffConf.name));
+auto ti = find(tariffs.begin(), tariffs.end(), TARIFF_IMPL(td.tariffConf.name));
if (ti == tariffs.end())
{
{
STG_LOCKER lock(&mutex);
- std::list<TARIFF_IMPL>::iterator ti;
- ti = find(tariffs.begin(), tariffs.end(), TARIFF_IMPL(name));
+ const auto ti = find(tariffs.begin(), tariffs.end(), TARIFF_IMPL(name));
if (ti == tariffs.end())
{
tariffs.erase(ti);
}
-std::set<NOTIFIER_BASE<TARIFF_DATA> *>::iterator ni = onDelNotifiers.begin();
+auto ni = onDelNotifiers.begin();
while (ni != onDelNotifiers.end())
{
(*ni)->Notify(td);
{
STG_LOCKER lock(&mutex);
- std::list<TARIFF_IMPL>::iterator ti;
- ti = find(tariffs.begin(), tariffs.end(), TARIFF_IMPL(name));
+ const auto ti = find(tariffs.begin(), tariffs.end(), TARIFF_IMPL(name));
if (ti != tariffs.end())
{
}
// Fire all "on add" notifiers
-std::set<NOTIFIER_BASE<TARIFF_DATA> *>::iterator ni = onAddNotifiers.begin();
+auto ni = onAddNotifiers.begin();
while (ni != onAddNotifiers.end())
{
(*ni)->Notify(tariffs.back().GetTariffData());
return 0;
}
//-----------------------------------------------------------------------------
-void TARIFFS_IMPL::GetTariffsData(std::list<TARIFF_DATA> * tdl) const
+void TARIFFS_IMPL::GetTariffsData(std::vector<TARIFF_DATA> * tdl) const
{
assert(tdl != NULL && "Tariffs data list is not null");
STG_LOCKER lock(&mutex);
-Tariffs::const_iterator it = tariffs.begin();
+auto it = tariffs.begin();
for (; it != tariffs.end(); ++it)
{
tdl->push_back(it->GetTariffData());
#include "tariff_impl.h"
#include <string>
-#include <list>
+#include <vector>
#include <set>
#include <pthread.h>
class TARIFFS_IMPL : public TARIFFS {
public:
- typedef std::list<TARIFF_IMPL> Tariffs;
+ using Tariffs = std::vector<TARIFF_IMPL>;
explicit TARIFFS_IMPL(STORE * store);
virtual ~TARIFFS_IMPL();
void AddNotifierDel(NOTIFIER_BASE<TARIFF_DATA> * notifier);
void DelNotifierDel(NOTIFIER_BASE<TARIFF_DATA> * notifier);
- void GetTariffsData(std::list<TARIFF_DATA> * tdl) const;
+ void GetTariffsData(std::vector<TARIFF_DATA> * tdl) const;
const std::string & GetStrError() const { return strError; }