X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/9dc2984179d989f8774ea7ff6d72c81d376b5a2c..fe97f14f9caa463e2bc6b81124ce5e9553bc924d:/projects/stargazer/plugins/configuration/sgconfig/parser_users.h diff --git a/projects/stargazer/plugins/configuration/sgconfig/parser_users.h b/projects/stargazer/plugins/configuration/sgconfig/parser_users.h index bd758f5a..4d03b7e8 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/parser_users.h +++ b/projects/stargazer/plugins/configuration/sgconfig/parser_users.h @@ -44,8 +44,21 @@ namespace PARSER class GET_USERS: public BASE_PARSER { public: + class FACTORY : public BASE_PARSER::FACTORY + { + public: + FACTORY(USERS & users) : m_users(users) {} + virtual BASE_PARSER * create(const ADMIN & admin) { return new GET_USERS(admin, m_users); } + static void Register(REGISTRY & registry, USERS & users) + { registry[tag] = new FACTORY(users); } + private: + USERS & m_users; + }; + + static const char * tag; + GET_USERS(const ADMIN & admin, USERS & users) - : BASE_PARSER(admin, "GetUsers"), m_users(users), + : BASE_PARSER(admin, tag), m_users(users), m_lastUserUpdateTime(0) {} int Start(void * data, const char * el, const char ** attr); @@ -59,8 +72,21 @@ class GET_USERS: public BASE_PARSER class GET_USER: public BASE_PARSER { public: + class FACTORY : public BASE_PARSER::FACTORY + { + public: + FACTORY(const USERS & users) : m_users(users) {} + virtual BASE_PARSER * create(const ADMIN & admin) { return new GET_USER(admin, m_users); } + static void Register(REGISTRY & registry, const USERS & users) + { registry[tag] = new FACTORY(users); } + private: + const USERS & m_users; + }; + + static const char * tag; + GET_USER(const ADMIN & admin, const USERS & users) - : BASE_PARSER(admin, "GetUser"), m_users(users) {} + : BASE_PARSER(admin, tag), m_users(users) {} int Start(void * data, const char * el, const char ** attr); private: @@ -73,8 +99,21 @@ class GET_USER: public BASE_PARSER class ADD_USER: public BASE_PARSER { public: + class FACTORY : public BASE_PARSER::FACTORY + { + public: + FACTORY(USERS & users) : m_users(users) {} + virtual BASE_PARSER * create(const ADMIN & admin) { return new ADD_USER(admin, m_users); } + static void Register(REGISTRY & registry, USERS & users) + { registry[tag] = new FACTORY(users); } + private: + USERS & m_users; + }; + + static const char * tag; + ADD_USER(const ADMIN & admin, USERS & users) - : BASE_PARSER(admin, "AddUser"), m_users(users) {} + : BASE_PARSER(admin, tag), m_users(users) {} int Start(void * data, const char * el, const char ** attr); private: @@ -87,9 +126,26 @@ class ADD_USER: public BASE_PARSER class CHG_USER: public BASE_PARSER { public: + class FACTORY : public BASE_PARSER::FACTORY + { + public: + FACTORY(USERS & users, STORE & store, const TARIFFS & tariffs) + : m_users(users), m_store(store), m_tariffs(tariffs) + {} + virtual BASE_PARSER * create(const ADMIN & admin) { return new CHG_USER(admin, m_users, m_store, m_tariffs); } + static void Register(REGISTRY & registry, USERS & users, STORE & store, const TARIFFS & tariffs) + { registry[tag] = new FACTORY(users, store, tariffs); } + private: + USERS & m_users; + STORE & m_store; + const TARIFFS & m_tariffs; + }; + + static const char * tag; + CHG_USER(const ADMIN & admin, USERS & users, STORE & store, const TARIFFS & tariffs) - : BASE_PARSER(admin, "SetUser"), + : BASE_PARSER(admin, tag), m_users(users), m_store(store), m_tariffs(tariffs), @@ -118,8 +174,21 @@ class CHG_USER: public BASE_PARSER class DEL_USER: public BASE_PARSER { public: + class FACTORY : public BASE_PARSER::FACTORY + { + public: + FACTORY(USERS & users) : m_users(users) {} + virtual BASE_PARSER * create(const ADMIN & admin) { return new DEL_USER(admin, m_users); } + static void Register(REGISTRY & registry, USERS & users) + { registry[tag] = new FACTORY(users); } + private: + USERS & m_users; + }; + + static const char * tag; + DEL_USER(const ADMIN & admin, USERS & users) - : BASE_PARSER(admin, "DelUser"), m_users(users), res(0), u(NULL) {} + : BASE_PARSER(admin, tag), m_users(users), res(0), u(NULL) {} int Start(void * data, const char * el, const char ** attr); int End(void * data, const char * el); @@ -134,8 +203,21 @@ class DEL_USER: public BASE_PARSER class CHECK_USER: public BASE_PARSER { public: + class FACTORY : public BASE_PARSER::FACTORY + { + public: + FACTORY(const USERS & users) : m_users(users) {} + virtual BASE_PARSER * create(const ADMIN & admin) { return new CHECK_USER(admin, m_users); } + static void Register(REGISTRY & registry, const USERS & users) + { registry[tag] = new FACTORY(users); } + private: + const USERS & m_users; + }; + + static const char * tag; + CHECK_USER(const ADMIN & admin, const USERS & users) - : BASE_PARSER(admin, "CheckUser"), m_users(users) {} + : BASE_PARSER(admin, tag), m_users(users) {} int Start(void * data, const char * el, const char ** attr); int End(void * data, const char * el); @@ -143,9 +225,10 @@ class CHECK_USER: public BASE_PARSER const USERS & m_users; void CreateAnswer(const char * error); + void CreateAnswer() {} // dummy }; -} -} +} // namespace PARSER +} // namespace STG #endif