]> git.stg.codes - stg.git/blob - projects/stargazer/plugins/configuration/sgconfig/parser_admins.h
Added parser factories.
[stg.git] / projects / stargazer / plugins / configuration / sgconfig / parser_admins.h
1 /*
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.
6  *
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.
11  *
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
15  */
16
17 /*
18  *    Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
19  *    Author : Maxim Mamontov <faust@stargazer.dp.ua>
20  */
21
22 #ifndef __STG_SGCONFIG_PARSER_ADMINS_H__
23 #define __STG_SGCONFIG_PARSER_ADMINS_H__
24
25 #include "parser.h"
26
27 #include "stg/resetable.h"
28
29 #include <string>
30
31 class ADMINS;
32 class ADMIN;
33
34 namespace STG
35 {
36 namespace PARSER
37 {
38
39 class GET_ADMINS: public BASE_PARSER
40 {
41     public:
42         class FACTORY : public BASE_PARSER::FACTORY
43         {
44             public:
45                 FACTORY(const ADMIN & admin, const ADMINS & admins)
46                     : m_admin(admin), m_admins(admins)
47                 {}
48                 virtual BASE_PARSER * create() { return new GET_ADMINS(m_admin, m_admins); }
49             private:
50                 const ADMIN & m_admin;
51                 const ADMINS & m_admins;
52         };
53
54         GET_ADMINS(const ADMIN & admin, const ADMINS & admins)
55             : BASE_PARSER(admin, "GetAdmins"), m_admins(admins) {}
56
57     private:
58         const ADMINS & m_admins;
59
60         void CreateAnswer();
61 };
62
63 class ADD_ADMIN: public BASE_PARSER
64 {
65     public:
66         class FACTORY : public BASE_PARSER::FACTORY
67         {
68             public:
69                 FACTORY(const ADMIN & admin, ADMINS & admins)
70                     : m_admin(admin), m_admins(admins)
71                 {}
72                 virtual BASE_PARSER * create() { return new ADD_ADMIN(m_admin, m_admins); }
73             private:
74                 const ADMIN & m_admin;
75                 ADMINS & m_admins;
76         };
77
78         ADD_ADMIN(const ADMIN & admin, ADMINS & admins)
79             : BASE_PARSER(admin, "AddAdmin"), m_admins(admins) {}
80         int Start(void * data, const char * el, const char ** attr);
81
82     private:
83         std::string m_admin;
84         ADMINS & m_admins;
85
86         void CreateAnswer();
87 };
88
89 class DEL_ADMIN: public BASE_PARSER
90 {
91     public:
92         class FACTORY : public BASE_PARSER::FACTORY
93         {
94             public:
95                 FACTORY(const ADMIN & admin, ADMINS & admins)
96                     : m_admin(admin), m_admins(admins)
97                 {}
98                 virtual BASE_PARSER * create() { return new DEL_ADMIN(m_admin, m_admins); }
99             private:
100                 const ADMIN & m_admin;
101                 ADMINS & m_admins;
102         };
103
104         DEL_ADMIN(const ADMIN & admin, ADMINS & admins)
105             : BASE_PARSER(admin, "DelAdmin"), m_admins(admins) {}
106         int Start(void * data, const char * el, const char ** attr);
107
108     private:
109         std::string m_admin;
110         ADMINS & m_admins;
111
112         void CreateAnswer();
113 };
114
115 class CHG_ADMIN: public BASE_PARSER
116 {
117     public:
118         class FACTORY : public BASE_PARSER::FACTORY
119         {
120             public:
121                 FACTORY(const ADMIN & admin, ADMINS & admins)
122                     : m_admin(admin), m_admins(admins)
123                 {}
124                 virtual BASE_PARSER * create() { return new CHG_ADMIN(m_admin, m_admins); }
125             private:
126                 const ADMIN & m_admin;
127                 ADMINS & m_admins;
128         };
129
130         CHG_ADMIN(const ADMIN & admin, ADMINS & admins)
131             : BASE_PARSER(admin, "ChgAdmin"), m_admins(admins) {}
132         int Start(void * data, const char * el, const char ** attr);
133
134     private:
135         std::string login;
136         RESETABLE<std::string> password;
137         RESETABLE<std::string> privAsString;
138         ADMINS & m_admins;
139
140         void CreateAnswer();
141 };
142
143 } // namespace PARSER
144 } // namespace STG
145
146 #endif