2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
19 * Author : Maxim Mamontov <faust@stargazer.dp.ua>
26 #include "stg/tariff_conf.h"
27 #include "stg/common.h"
41 class GET_TARIFFS: public BASE_PARSER
44 class FACTORY : public BASE_PARSER::FACTORY
47 explicit FACTORY(const Tariffs & tariffs) : m_tariffs(tariffs) {}
48 BASE_PARSER * create(const Admin & admin) override { return new GET_TARIFFS(admin, m_tariffs); }
49 static void Register(REGISTRY & registry, const Tariffs & tariffs)
50 { registry[ToLower(tag)] = new FACTORY(tariffs); }
52 const Tariffs & m_tariffs;
55 static const char * tag;
57 GET_TARIFFS(const Admin & admin, const Tariffs & tariffs)
58 : BASE_PARSER(admin, tag), m_tariffs(tariffs) {}
61 const Tariffs & m_tariffs;
63 void CreateAnswer() override;
66 class ADD_TARIFF: public BASE_PARSER
69 class FACTORY : public BASE_PARSER::FACTORY
72 explicit FACTORY(Tariffs & tariffs) : m_tariffs(tariffs) {}
73 BASE_PARSER * create(const Admin & admin) override { return new ADD_TARIFF(admin, m_tariffs); }
74 static void Register(REGISTRY & registry, Tariffs & tariffs)
75 { registry[ToLower(tag)] = new FACTORY(tariffs); }
80 static const char * tag;
82 ADD_TARIFF(const Admin & admin, Tariffs & tariffs)
83 : BASE_PARSER(admin, tag), m_tariffs(tariffs) {}
84 int Start(void * data, const char * el, const char ** attr) override;
90 void CreateAnswer() override;
93 class DEL_TARIFF: public BASE_PARSER
96 class FACTORY : public BASE_PARSER::FACTORY
99 FACTORY(Tariffs & tariffs, const Users & users) : m_tariffs(tariffs), m_users(users) {}
100 BASE_PARSER * create(const Admin & admin) override { return new DEL_TARIFF(admin, m_users, m_tariffs); }
101 static void Register(REGISTRY & registry, Tariffs & tariffs, const Users & users)
102 { registry[ToLower(tag)] = new FACTORY(tariffs, users); }
105 const Users & m_users;
108 static const char * tag;
110 DEL_TARIFF(const Admin & admin, const Users & users, Tariffs & tariffs)
111 : BASE_PARSER(admin, tag), m_users(users), m_tariffs(tariffs) {}
112 int Start(void * data, const char * el, const char ** attr) override;
116 const Users & m_users;
119 void CreateAnswer() override;
122 class CHG_TARIFF: public BASE_PARSER
125 class FACTORY : public BASE_PARSER::FACTORY
128 explicit FACTORY(Tariffs & tariffs) : m_tariffs(tariffs) {}
129 BASE_PARSER * create(const Admin & admin) override { return new CHG_TARIFF(admin, m_tariffs); }
130 static void Register(REGISTRY & registry, Tariffs & tariffs)
131 { registry[ToLower(tag)] = new FACTORY(tariffs); }
136 static const char * tag;
138 CHG_TARIFF(const Admin & admin, Tariffs & tariffs)
139 : BASE_PARSER(admin, tag), m_tariffs(tariffs) {}
140 int Start(void * data, const char * el, const char ** attr) override;
146 int CheckTariffData();
147 void CreateAnswer() override;
150 } // namespace PARSER