]> git.stg.codes - stg.git/blob - projects/stargazer/plugins/configuration/sgconfig/parser_services.h
Merge branch 'stg-2.409-radius'
[stg.git] / projects / stargazer / plugins / configuration / sgconfig / parser_services.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 : Maxim Mamontov <faust@stargazer.dp.ua>
19  */
20
21 #ifndef __STG_SGCONFIG_PARSER_SERVICES_H__
22 #define __STG_SGCONFIG_PARSER_SERVICES_H__
23
24 #include "parser.h"
25
26 #include "stg/service_conf.h"
27
28 #include "stg/common.h"
29
30 #include <string>
31
32 class SERVICES;
33
34 namespace STG
35 {
36 namespace PARSER
37 {
38
39 class GET_SERVICES: public BASE_PARSER
40 {
41     public:
42         class FACTORY : public BASE_PARSER::FACTORY
43         {
44             public:
45                 FACTORY(const SERVICES & services) : m_services(services) {}
46                 virtual BASE_PARSER * create(const ADMIN & admin) { return new GET_SERVICES(admin, m_services); }
47                 static void Register(REGISTRY & registry, const SERVICES & services)
48                 { registry[ToLower(tag)] = new FACTORY(services); }
49             private:
50                 const SERVICES & m_services;
51         };
52
53         static const char * tag;
54
55         GET_SERVICES(const ADMIN & admin, const SERVICES & services)
56             : BASE_PARSER(admin, tag), m_services(services) {}
57
58     private:
59         const SERVICES & m_services;
60
61         void CreateAnswer();
62 };
63
64 class GET_SERVICE: public BASE_PARSER
65 {
66     public:
67         class FACTORY : public BASE_PARSER::FACTORY
68         {
69             public:
70                 FACTORY(const SERVICES & services) : m_services(services) {}
71                 virtual BASE_PARSER * create(const ADMIN & admin) { return new GET_SERVICE(admin, m_services); }
72                 static void Register(REGISTRY & registry, SERVICES & services)
73                 { registry[ToLower(tag)] = new FACTORY(services); }
74             private:
75                 const SERVICES & m_services;
76         };
77
78         static const char * tag;
79
80         GET_SERVICE(const ADMIN & admin, const SERVICES & services)
81             : BASE_PARSER(admin, tag), m_services(services) {}
82         int Start(void * data, const char * el, const char ** attr);
83
84     private:
85         std::string m_name;
86         const SERVICES & m_services;
87
88         void CreateAnswer();
89 };
90
91 class ADD_SERVICE: public BASE_PARSER
92 {
93     public:
94         class FACTORY : public BASE_PARSER::FACTORY
95         {
96             public:
97                 FACTORY(SERVICES & services) : m_services(services) {}
98                 virtual BASE_PARSER * create(const ADMIN & admin) { return new ADD_SERVICE(admin, m_services); }
99                 static void Register(REGISTRY & registry, SERVICES & services)
100                 { registry[ToLower(tag)] = new FACTORY(services); }
101             private:
102                 SERVICES & m_services;
103         };
104
105         static const char * tag;
106
107         ADD_SERVICE(const ADMIN & admin, SERVICES & services)
108             : BASE_PARSER(admin, tag), m_services(services) {}
109         int Start(void * data, const char * el, const char ** attr);
110
111     private:
112         std::string m_name;
113         SERVICES & m_services;
114
115         void CreateAnswer();
116 };
117
118 class DEL_SERVICE: public BASE_PARSER
119 {
120     public:
121         class FACTORY : public BASE_PARSER::FACTORY
122         {
123             public:
124                 FACTORY(SERVICES & services) : m_services(services) {}
125                 virtual BASE_PARSER * create(const ADMIN & admin) { return new DEL_SERVICE(admin, m_services); }
126                 static void Register(REGISTRY & registry, SERVICES & services)
127                 { registry[ToLower(tag)] = new FACTORY(services); }
128             private:
129                 SERVICES & m_services;
130         };
131
132         static const char * tag;
133
134         DEL_SERVICE(const ADMIN & admin, SERVICES & services)
135             : BASE_PARSER(admin, tag), m_services(services) {}
136         int Start(void * data, const char * el, const char ** attr);
137
138     private:
139         std::string m_name;
140         SERVICES & m_services;
141
142         void CreateAnswer();
143 };
144
145 class CHG_SERVICE: public BASE_PARSER
146 {
147     public:
148         class FACTORY : public BASE_PARSER::FACTORY
149         {
150             public:
151                 FACTORY(SERVICES & services) : m_services(services) {}
152                 virtual BASE_PARSER * create(const ADMIN & admin) { return new CHG_SERVICE(admin, m_services); }
153                 static void Register(REGISTRY & registry, SERVICES & services)
154                 { registry[ToLower(tag)] = new FACTORY(services); }
155             private:
156                 SERVICES & m_services;
157         };
158
159         static const char * tag;
160
161         CHG_SERVICE(const ADMIN & admin, SERVICES & services)
162             : BASE_PARSER(admin, tag), m_services(services) {}
163         int Start(void * data, const char * el, const char ** attr);
164
165     private:
166         SERVICE_CONF_RES m_service;
167         SERVICES & m_services;
168
169         void CreateAnswer();
170 };
171
172 } // namespace PARSER
173 } // namespace STG
174
175 #endif