X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/6171920df2f880303b54c19d7c5169c64b485585..1487578f4887f49661320e24e311074a9af36f80:/projects/stargazer/plugins/configuration/sgconfig/parser_users.h?ds=sidebyside diff --git a/projects/stargazer/plugins/configuration/sgconfig/parser_users.h b/projects/stargazer/plugins/configuration/sgconfig/parser_users.h index f5db4e7b..c9f72389 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/parser_users.h +++ b/projects/stargazer/plugins/configuration/sgconfig/parser_users.h @@ -26,6 +26,7 @@ #include "stg/user_conf.h" #include "stg/user_stat.h" +#include "stg/common.h" #include "stg/resetable.h" #include @@ -47,17 +48,18 @@ class GET_USERS: public BASE_PARSER class FACTORY : public BASE_PARSER::FACTORY { public: - FACTORY(const ADMIN & admin, USERS & users) - : m_admin(admin), m_users(users) - {} - virtual BASE_PARSER * create() { return new GET_USERS(m_admin, m_users); } + 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[ToLower(tag)] = new FACTORY(users); } private: - const ADMIN & m_admin; 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); @@ -74,17 +76,18 @@ class GET_USER: public BASE_PARSER class FACTORY : public BASE_PARSER::FACTORY { public: - FACTORY(const ADMIN & admin, const USERS & users) - : m_admin(admin), m_users(users) - {} - virtual BASE_PARSER * create() { return new GET_USER(m_admin, m_users); } + 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[ToLower(tag)] = new FACTORY(users); } private: - const ADMIN & m_admin; 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: @@ -100,17 +103,18 @@ class ADD_USER: public BASE_PARSER class FACTORY : public BASE_PARSER::FACTORY { public: - FACTORY(const ADMIN & admin, USERS & users) - : m_admin(admin), m_users(users) - {} - virtual BASE_PARSER * create() { return new ADD_USER(m_admin, m_users); } + 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[ToLower(tag)] = new FACTORY(users); } private: - const ADMIN & m_admin; 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: @@ -126,25 +130,27 @@ class CHG_USER: public BASE_PARSER class FACTORY : public BASE_PARSER::FACTORY { public: - FACTORY(const ADMIN & admin, USERS & users, STORE & store, const TARIFFS & tariffs) - : m_admin(admin), m_users(users), m_store(store), m_tariffs(tariffs) + FACTORY(USERS & users, STORE & store, const TARIFFS & tariffs) + : m_users(users), m_store(store), m_tariffs(tariffs) {} - virtual BASE_PARSER * create() { return new CHG_USER(m_admin, m_users, m_store, m_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[ToLower(tag)] = new FACTORY(users, store, tariffs); } private: - const ADMIN & m_admin; 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), - m_cashMustBeAdded(false), - m_res(0) {} + m_cashMustBeAdded(false) {} int Start(void * data, const char * el, const char ** attr); @@ -159,7 +165,6 @@ class CHG_USER: public BASE_PARSER std::string m_cashMsg; std::string m_login; bool m_cashMustBeAdded; - int m_res; int ApplyChanges(); void CreateAnswer(); @@ -171,17 +176,18 @@ class DEL_USER: public BASE_PARSER class FACTORY : public BASE_PARSER::FACTORY { public: - FACTORY(const ADMIN & admin, USERS & users) - : m_admin(admin), m_users(users) - {} - virtual BASE_PARSER * create() { return new DEL_USER(m_admin, m_users); } + 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[ToLower(tag)] = new FACTORY(users); } private: - const ADMIN & m_admin; 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); @@ -199,17 +205,18 @@ class CHECK_USER: public BASE_PARSER class FACTORY : public BASE_PARSER::FACTORY { public: - FACTORY(const ADMIN & admin, const USERS & users) - : m_admin(admin), m_users(users) - {} - virtual BASE_PARSER * create() { return new CHECK_USER(m_admin, m_users); } + 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[ToLower(tag)] = new FACTORY(users); } private: - const ADMIN & m_admin; 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);