#include "conn.h"
+#include "parser_server_info.h"
+#include "parser_admins.h"
+#include "parser_tariffs.h"
+#include "parser_users.h"
+#include "parser_message.h"
+#include "parser_user_info.h"
+#include "parser_auth_by.h"
+
#include "stg/common.h"
#include "stg/logger.h"
#include <netinet/in.h>
#include <arpa/inet.h>
+namespace SP = STG::PARSER;
+
namespace
{
m_stopped(true),
m_logger(l),
m_listenSocket(-1)
+{
+}
+
+CONFIGPROTO::~CONFIGPROTO()
{
std::for_each(m_conns.begin(), m_conns.end(), RemoveConn());
}
return -1;
}
+ RegisterParsers();
+
m_running = true;
m_stopped = false;
return 0;
m_stopped = true;
}
+void CONFIGPROTO::RegisterParsers()
+{
+ assert(m_settings != NULL);
+ assert(m_store != NULL);
+ assert(m_admins != NULL);
+ assert(m_users != NULL);
+ assert(m_tariffs != NULL);
+
+ SP::GET_SERVER_INFO::FACTORY::Register(m_registry, *m_settings, *m_users, *m_tariffs);
+
+ SP::GET_ADMINS::FACTORY::Register(m_registry, *m_admins);
+ SP::ADD_ADMIN::FACTORY::Register(m_registry, *m_admins);
+ SP::DEL_ADMIN::FACTORY::Register(m_registry, *m_admins);
+ SP::CHG_ADMIN::FACTORY::Register(m_registry, *m_admins);
+
+ SP::GET_TARIFFS::FACTORY::Register(m_registry, *m_tariffs);
+ SP::ADD_TARIFF::FACTORY::Register(m_registry, *m_tariffs);
+ SP::DEL_TARIFF::FACTORY::Register(m_registry, *m_tariffs, *m_users);
+ SP::CHG_TARIFF::FACTORY::Register(m_registry, *m_tariffs);
+
+ SP::GET_USERS::FACTORY::Register(m_registry, *m_users);
+ SP::GET_USER::FACTORY::Register(m_registry, *m_users);
+ SP::ADD_USER::FACTORY::Register(m_registry, *m_users);
+ SP::DEL_USER::FACTORY::Register(m_registry, *m_users);
+ SP::CHG_USER::FACTORY::Register(m_registry, *m_users, *m_store, *m_tariffs);
+ SP::CHECK_USER::FACTORY::Register(m_registry, *m_users);
+
+ SP::SEND_MESSAGE::FACTORY::Register(m_registry, *m_users);
+
+ SP::AUTH_BY::FACTORY::Register(m_registry, *m_users);
+
+ SP::USER_INFO::FACTORY::Register(m_registry, *m_users);
+}
+
int CONFIGPROTO::MaxFD() const
{
int maxFD = m_listenSocket;
return;
}
- assert(m_settings != NULL);
assert(m_admins != NULL);
- assert(m_users != NULL);
- assert(m_tariffs != NULL);
try
{
- m_conns.push_back(new STG::Conn(*m_settings, *m_admins, *m_users, *m_tariffs, sock, outerAddr));
+ m_conns.push_back(new STG::Conn(m_registry, *m_admins, sock, outerAddr));
printfd(__FILE__, "New connection from %s:%d\n", inet_ntostring(m_conns.back()->IP()).c_str(), m_conns.back()->Port());
}
catch (const STG::Conn::Error & error)
#ifndef CONFIGPROTO_H
#define CONFIGPROTO_H
+#include "parser.h"
+
#include "stg/module_settings.h"
#include "stg/os_int.h"
class ADMINS;
class TARIFFS;
class USERS;
+class STORE;
class PLUGIN_LOGGER;
namespace STG
class CONFIGPROTO {
public:
CONFIGPROTO(PLUGIN_LOGGER & l);
+ ~CONFIGPROTO();
void SetPort(uint16_t port) { m_port = port; }
void SetSettings(const SETTINGS * settings) { m_settings = settings; }
void SetAdmins(ADMINS * admins) { m_admins = admins; }
void SetTariffs(TARIFFS * tariffs) { m_tariffs = tariffs; }
void SetUsers(USERS * users) { m_users = users; }
+ void SetStore(STORE * store) { m_store = store; }
int Prepare();
int Stop();
ADMINS * m_admins;
TARIFFS * m_tariffs;
USERS * m_users;
+ STORE * m_store;
uint16_t m_port;
bool m_running;
std::string m_errorStr;
+ BASE_PARSER::REGISTRY m_registry;
std::vector<STG::Conn *> m_conns;
+ void RegisterParsers();
+
int MaxFD() const;
void BuildFDSet(fd_set & fds) const;
void CleanupConns();
#include "conn.h"
-#include "parser.h"
-
-#include "parser_server_info.h"
-#include "parser_admins.h"
-#include "parser_tariffs.h"
-#include "parser_users.h"
-#include "parser_message.h"
-#include "parser_auth_by.h"
-#include "parser_user_info.h"
-
-#include "stg/settings.h"
#include "stg/admins.h"
-#include "stg/users.h"
-#include "stg/tariffs.h"
#include "stg/admin.h"
#include "stg/blowfish.h"
#include "stg/bfstream.h"
#include "stg/common.h"
#include <cassert>
+#include <cstring>
#include <unistd.h>
#include <sys/socket.h>
const char Conn::OK_LOGINS[] = "OKLS";
const char Conn::ERR_LOGINS[] = "ERLS";
-Conn::Conn(const SETTINGS & settings,
- ADMINS & admins,
- USERS & users,
- TARIFFS & tariffs,
- int sock, const sockaddr_in& addr)
- : m_settings(settings),
+Conn::Conn(const BASE_PARSER::REGISTRY & registry,
+ ADMINS & admins, int sock, const sockaddr_in& addr)
+ : m_registry(registry),
m_admins(admins),
- m_users(users),
- m_tariffs(tariffs),
m_admin(NULL),
m_sock(sock),
m_addr(addr),
shutdown(m_sock, SHUT_RDWR);
close(m_sock);
- /*std::map<std::string, BASE_PARSER *>::iterator it(m_parsers.begin());
- for (; it != m_parsers.end(); ++it)
- delete it->second;*/
XML_ParserFree(m_xmlParser);
}
return true;
}
-BASE_PARSER * Conn::GetParser(const std::string & tag)
+BASE_PARSER * Conn::GetParser(const std::string & tag) const
{
- if (strcasecmp(tag.c_str(), "getserverinfo") == 0)
- return new STG::PARSER::GET_SERVER_INFO(*m_admin, m_settings, m_users, m_tariffs);
- if (strcasecmp(tag.c_str(), "getadmins") == 0)
- return new STG::PARSER::GET_ADMINS(*m_admin, m_admins);
- if (strcasecmp(tag.c_str(), "addadmin") == 0)
- return new STG::PARSER::ADD_ADMIN(*m_admin, m_admins);
- if (strcasecmp(tag.c_str(), "deladmin") == 0)
- return new STG::PARSER::DEL_ADMIN(*m_admin, m_admins);
- if (strcasecmp(tag.c_str(), "chgadmin") == 0)
- return new STG::PARSER::CHG_ADMIN(*m_admin, m_admins);
- return NULL;
+ BASE_PARSER::REGISTRY::const_iterator it = m_registry.find(tag);
+ if (it == m_registry.end())
+ return NULL;
+ return it->second->create(*m_admin);
}
bool Conn::HandleBuffer(size_t size)
#ifndef __STG_SGCONFIG_CONN_H__
#define __STG_SGCONFIG_CONN_H__
+#include "parser.h"
+
#include "stg/os_int.h"
#include "stg/const.h"
#include <stdexcept>
#include <string>
-#include <map>
#include <expat.h>
Error(const std::string& message) : runtime_error(message.c_str()) {}
};
- Conn(const SETTINGS & settings,
- ADMINS & admins,
- USERS & users,
- TARIFFS & tariffs,
- int sock, const sockaddr_in& addr);
+ Conn(const BASE_PARSER::REGISTRY & registry,
+ ADMINS & admins, int sock, const sockaddr_in& addr);
~Conn();
int Sock() const { return m_sock; }
static const char OK_LOGINS[5];
static const char ERR_LOGINS[5];
- const SETTINGS & m_settings;
+ const BASE_PARSER::REGISTRY & m_registry;
+
ADMINS & m_admins;
- USERS & m_users;
- TARIFFS & m_tariffs;
ADMIN * m_admin;
char m_data[1024];
STG::DECRYPT_STREAM * m_stream;
- BASE_PARSER * GetParser(const std::string & tag);
+ BASE_PARSER * GetParser(const std::string & tag) const;
bool HandleBuffer(size_t size);
#define PARSER_H
#include <string>
+#include <map>
class ADMIN;
public:
struct FACTORY
{
- virtual BASE_PARSER * create() = 0;
+ virtual BASE_PARSER * create(const ADMIN & admin) = 0;
};
+ typedef std::map<std::string, FACTORY *> REGISTRY;
BASE_PARSER(const ADMIN & admin, const std::string & t)
: m_currAdmin(admin),
using STG::PARSER::DEL_ADMIN;
using STG::PARSER::CHG_ADMIN;
+const char * GET_ADMINS::tag = "GetAdmins";
+const char * ADD_ADMIN::tag = "AddAdmin";
+const char * DEL_ADMIN::tag = "DelAdmin";
+const char * CHG_ADMIN::tag = "ChgAdmin";
+
void GET_ADMINS::CreateAnswer()
{
const PRIV * priv = m_currAdmin.GetPriv();
class FACTORY : public BASE_PARSER::FACTORY
{
public:
- FACTORY(const ADMIN & admin, const ADMINS & admins)
- : m_admin(admin), m_admins(admins)
- {}
- virtual BASE_PARSER * create() { return new GET_ADMINS(m_admin, m_admins); }
+ FACTORY(const ADMINS & admins) : m_admins(admins) {}
+ virtual BASE_PARSER * create(const ADMIN & admin) { return new GET_ADMINS(admin, m_admins); }
+ static void Register(REGISTRY & registry, const ADMINS & admins)
+ { registry[tag] = new FACTORY(admins); }
private:
- const ADMIN & m_admin;
const ADMINS & m_admins;
};
+ static const char * tag;
+
GET_ADMINS(const ADMIN & admin, const ADMINS & admins)
- : BASE_PARSER(admin, "GetAdmins"), m_admins(admins) {}
+ : BASE_PARSER(admin, tag), m_admins(admins) {}
private:
const ADMINS & m_admins;
class FACTORY : public BASE_PARSER::FACTORY
{
public:
- FACTORY(const ADMIN & admin, ADMINS & admins)
- : m_admin(admin), m_admins(admins)
- {}
- virtual BASE_PARSER * create() { return new ADD_ADMIN(m_admin, m_admins); }
+ FACTORY(ADMINS & admins) : m_admins(admins) {}
+ virtual BASE_PARSER * create(const ADMIN & admin) { return new ADD_ADMIN(admin, m_admins); }
+ static void Register(REGISTRY & registry, ADMINS & admins)
+ { registry[tag] = new FACTORY(admins); }
private:
- const ADMIN & m_admin;
ADMINS & m_admins;
};
+ static const char * tag;
+
ADD_ADMIN(const ADMIN & admin, ADMINS & admins)
- : BASE_PARSER(admin, "AddAdmin"), m_admins(admins) {}
+ : BASE_PARSER(admin, tag), m_admins(admins) {}
int Start(void * data, const char * el, const char ** attr);
private:
class FACTORY : public BASE_PARSER::FACTORY
{
public:
- FACTORY(const ADMIN & admin, ADMINS & admins)
- : m_admin(admin), m_admins(admins)
- {}
- virtual BASE_PARSER * create() { return new DEL_ADMIN(m_admin, m_admins); }
+ FACTORY(ADMINS & admins) : m_admins(admins) {}
+ virtual BASE_PARSER * create(const ADMIN & admin) { return new DEL_ADMIN(admin, m_admins); }
+ static void Register(REGISTRY & registry, ADMINS & admins)
+ { registry[tag] = new FACTORY(admins); }
private:
- const ADMIN & m_admin;
ADMINS & m_admins;
};
+ static const char * tag;
+
DEL_ADMIN(const ADMIN & admin, ADMINS & admins)
- : BASE_PARSER(admin, "DelAdmin"), m_admins(admins) {}
+ : BASE_PARSER(admin, tag), m_admins(admins) {}
int Start(void * data, const char * el, const char ** attr);
private:
class FACTORY : public BASE_PARSER::FACTORY
{
public:
- FACTORY(const ADMIN & admin, ADMINS & admins)
- : m_admin(admin), m_admins(admins)
- {}
- virtual BASE_PARSER * create() { return new CHG_ADMIN(m_admin, m_admins); }
+ FACTORY(ADMINS & admins) : m_admins(admins) {}
+ virtual BASE_PARSER * create(const ADMIN & admin) { return new CHG_ADMIN(admin, m_admins); }
+ static void Register(REGISTRY & registry, ADMINS & admins)
+ { registry[tag] = new FACTORY(admins); }
private:
- const ADMIN & m_admin;
ADMINS & m_admins;
};
+ static const char * tag;
+
CHG_ADMIN(const ADMIN & admin, ADMINS & admins)
- : BASE_PARSER(admin, "ChgAdmin"), m_admins(admins) {}
+ : BASE_PARSER(admin, tag), m_admins(admins) {}
int Start(void * data, const char * el, const char ** attr);
private:
using STG::PARSER::AUTH_BY;
+const char * AUTH_BY::tag = "GetUserAuthBy";
+
int AUTH_BY::Start(void * /*data*/, const char *el, const char **attr)
{
if (strcasecmp(el, m_tag.c_str()) != 0)
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 AUTH_BY(m_admin, m_users); }
+ FACTORY(const USERS & users) : m_users(users) {}
+ virtual BASE_PARSER * create(const ADMIN & admin) { return new AUTH_BY(admin, m_users); }
+ static void Register(REGISTRY & registry, const USERS & users)
+ { registry[tag] = new FACTORY(users); }
private:
- const ADMIN & m_admin;
const USERS & m_users;
};
+ static const char * tag;
+
AUTH_BY(const ADMIN & admin, const USERS & users)
- : BASE_PARSER(admin, "GetUserAuthBy"), m_users(users) {}
+ : BASE_PARSER(admin, tag), m_users(users) {}
int Start(void * data, const char * el, const char ** attr);
private:
using STG::PARSER::SEND_MESSAGE;
+const char * SEND_MESSAGE::tag = "Message";
+
int SEND_MESSAGE::Start(void *, const char *el, const char **attr)
{
if (strcasecmp(el, m_tag.c_str()) != 0)
* Author : Maxim Mamontov <faust@stargazer.dp.ua>
*/
-#ifndef __STG_SGCONFIG_PARSER_USERS_H__
-#define __STG_SGCONFIG_PARSER_USERS_H__
+#ifndef __STG_SGCONFIG_PARSER_SEND_MESSAGE_H__
+#define __STG_SGCONFIG_PARSER_SEND_MESSAGE_H__
#include "parser.h"
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 SEND_MESSAGE(m_admin, m_users); }
+ FACTORY(USERS & users) : m_users(users) {}
+ virtual BASE_PARSER * create(const ADMIN & admin) { return new SEND_MESSAGE(admin, m_users); }
+ static void Register(REGISTRY & registry, USERS & users)
+ { registry[tag] = new FACTORY(users); }
private:
- const ADMIN & m_admin;
USERS & m_users;
};
+ static const char * tag;
+
SEND_MESSAGE(const ADMIN & admin, USERS & users)
- : BASE_PARSER(admin, "Message"), m_users(users), m_result(res_ok), m_user(NULL) {}
+ : BASE_PARSER(admin, tag), m_users(users), m_result(res_ok), m_user(NULL) {}
int Start(void *data, const char *el, const char **attr);
int End(void *data, const char *el);
using STG::PARSER::GET_SERVER_INFO;
+const char * GET_SERVER_INFO::tag = "GetServerInfo";
+
void GET_SERVER_INFO::CreateAnswer()
{
struct utsname utsn;
class GET_SERVER_INFO: public BASE_PARSER {
public:
+ class FACTORY : public BASE_PARSER::FACTORY
+ {
+ public:
+ FACTORY(const SETTINGS & settings, const USERS & users, const TARIFFS & tariffs)
+ : m_settings(settings), m_users(users), m_tariffs(tariffs) {}
+ virtual BASE_PARSER * create(const ADMIN & admin) { return new GET_SERVER_INFO(admin, m_settings, m_users, m_tariffs); }
+ static void Register(REGISTRY & registry, const SETTINGS & settings, const USERS & users, const TARIFFS & tariffs)
+ { registry[tag] = new FACTORY(settings, users, tariffs); }
+ private:
+ const SETTINGS & m_settings;
+ const USERS & m_users;
+ const TARIFFS & m_tariffs;
+ };
+
+ static const char * tag;
+
GET_SERVER_INFO(const ADMIN & admin,
const SETTINGS & settings,
const USERS & users,
const TARIFFS & tariffs)
- : BASE_PARSER(admin, "GetServerInfo"),
+ : BASE_PARSER(admin, tag),
m_settings(settings),
m_users(users),
m_tariffs(tariffs)
using STG::PARSER::DEL_TARIFF;
using STG::PARSER::CHG_TARIFF;
+const char * GET_TARIFFS::tag = "GetTariffs";
+const char * ADD_TARIFF::tag = "AddTariff";
+const char * DEL_TARIFF::tag = "DelTariff";
+const char * CHG_TARIFF::tag = "SetTariff";
+
namespace
{
class FACTORY : public BASE_PARSER::FACTORY
{
public:
- FACTORY(const ADMIN & admin, const TARIFFS & tariffs)
- : m_admin(admin), m_tariffs(tariffs)
- {}
- virtual BASE_PARSER * create() { return new GET_TARIFFS(m_admin, m_tariffs); }
+ FACTORY(const TARIFFS & tariffs) : m_tariffs(tariffs) {}
+ virtual BASE_PARSER * create(const ADMIN & admin) { return new GET_TARIFFS(admin, m_tariffs); }
+ static void Register(REGISTRY & registry, const TARIFFS & tariffs)
+ { registry[tag] = new FACTORY(tariffs); }
private:
- const ADMIN & m_admin;
const TARIFFS & m_tariffs;
};
+ static const char * tag;
+
GET_TARIFFS(const ADMIN & admin, const TARIFFS & tariffs)
- : BASE_PARSER(admin, "GetTariffs"), m_tariffs(tariffs) {}
+ : BASE_PARSER(admin, tag), m_tariffs(tariffs) {}
private:
const TARIFFS & m_tariffs;
class FACTORY : public BASE_PARSER::FACTORY
{
public:
- FACTORY(const ADMIN & admin, TARIFFS & tariffs)
- : m_admin(admin), m_tariffs(tariffs)
- {}
- virtual BASE_PARSER * create() { return new ADD_TARIFF(m_admin, m_tariffs); }
+ FACTORY(TARIFFS & tariffs) : m_tariffs(tariffs) {}
+ virtual BASE_PARSER * create(const ADMIN & admin) { return new ADD_TARIFF(admin, m_tariffs); }
+ static void Register(REGISTRY & registry, TARIFFS & tariffs)
+ { registry[tag] = new FACTORY(tariffs); }
private:
- const ADMIN & m_admin;
TARIFFS & m_tariffs;
};
+ static const char * tag;
+
ADD_TARIFF(const ADMIN & admin, TARIFFS & tariffs)
- : BASE_PARSER(admin, "AddTariff"), m_tariffs(tariffs) {}
+ : BASE_PARSER(admin, tag), m_tariffs(tariffs) {}
int Start(void * data, const char * el, const char ** attr);
private:
class FACTORY : public BASE_PARSER::FACTORY
{
public:
- FACTORY(const ADMIN & admin, TARIFFS & tariffs, const USERS & users)
- : m_admin(admin), m_tariffs(tariffs), m_users(users)
- {}
- virtual BASE_PARSER * create() { return new DEL_TARIFF(m_admin, m_users, m_tariffs); }
+ FACTORY(TARIFFS & tariffs, const USERS & users) : m_tariffs(tariffs), m_users(users) {}
+ virtual BASE_PARSER * create(const ADMIN & admin) { return new DEL_TARIFF(admin, m_users, m_tariffs); }
+ static void Register(REGISTRY & registry, TARIFFS & tariffs, const USERS & users)
+ { registry[tag] = new FACTORY(tariffs, users); }
private:
- const ADMIN & m_admin;
TARIFFS & m_tariffs;
const USERS & m_users;
};
+ static const char * tag;
+
DEL_TARIFF(const ADMIN & admin, const USERS & users, TARIFFS & tariffs)
- : BASE_PARSER(admin, "DelTariff"), m_users(users), m_tariffs(tariffs) {}
+ : BASE_PARSER(admin, tag), m_users(users), m_tariffs(tariffs) {}
int Start(void * data, const char * el, const char ** attr);
private:
class FACTORY : public BASE_PARSER::FACTORY
{
public:
- FACTORY(const ADMIN & admin, TARIFFS & tariffs)
- : m_admin(admin), m_tariffs(tariffs)
- {}
- virtual BASE_PARSER * create() { return new CHG_TARIFF(m_admin, m_tariffs); }
+ FACTORY(TARIFFS & tariffs) : m_tariffs(tariffs) {}
+ virtual BASE_PARSER * create(const ADMIN & admin) { return new CHG_TARIFF(admin, m_tariffs); }
+ static void Register(REGISTRY & registry, TARIFFS & tariffs)
+ { registry[tag] = new FACTORY(tariffs); }
private:
- const ADMIN & m_admin;
TARIFFS & m_tariffs;
};
+ static const char * tag;
+
CHG_TARIFF(const ADMIN & admin, TARIFFS & tariffs)
- : BASE_PARSER(admin, "SetTariff"), m_tariffs(tariffs) {}
+ : BASE_PARSER(admin, tag), m_tariffs(tariffs) {}
int Start(void * data, const char * el, const char ** attr);
private:
using STG::PARSER::CHG_USER;
using STG::PARSER::CHECK_USER;
+const char * GET_USERS::tag = "GetUsers";
+const char * GET_USER::tag = "GetUser";
+const char * ADD_USER::tag = "AddUser";
+const char * CHG_USER::tag = "SetUser";
+const char * DEL_USER::tag = "DelUser";
+const char * CHECK_USER::tag = "CheckUser";
+
namespace
{
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[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);
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[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:
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[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:
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[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),
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[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);
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[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);
void SetUsers(USERS * users) { config.SetUsers(users); }
void SetTariffs(TARIFFS * tariffs) { config.SetTariffs(tariffs); }
void SetAdmins(ADMINS * admins) { config.SetAdmins(admins); }
- void SetStore(STORE *) {}
+ void SetStore(STORE * store) { config.SetStore(store); }
void SetStgSettings(const SETTINGS * s) { config.SetSettings(s); }
void SetSettings(const MODULE_SETTINGS & s) { settings = s; }
int ParseSettings();