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.
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.
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
18 * Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
19 * Author : Maxim Mamontov <faust@stargazer.dp.ua>
26 #include "stg/module_settings.h"
30 #pragma GCC diagnostic push
31 #pragma GCC diagnostic ignored "-Wshadow"
32 #include <jthread.hpp>
33 #pragma GCC diagnostic pop
36 #include <sys/select.h>
37 #include <sys/types.h>
58 explicit CONFIGPROTO(STG::PluginLogger & l);
61 void SetPort(uint16_t port) { m_port = port; }
62 void SetBindAddress(const std::string & address) { m_bindAddress = address; }
63 void SetSettings(const STG::Settings * settings) { m_settings = settings; }
64 void SetAdmins(STG::Admins * admins) { m_admins = admins; }
65 void SetTariffs(STG::Tariffs * tariffs) { m_tariffs = tariffs; }
66 void SetUsers(STG::Users * users) { m_users = users; }
67 void SetStore(STG::Store * store) { m_store = store; }
68 void SetServices(STG::Services * services) { m_services = services; }
69 void SetCorporations(STG::Corporations * corporations) { m_corporations = corporations; }
73 const std::string & GetStrError() const { return m_errorStr; }
74 void Run(std::stop_token token);
77 CONFIGPROTO(const CONFIGPROTO & rvalue);
78 CONFIGPROTO & operator=(const CONFIGPROTO & rvalue);
80 const STG::Settings * m_settings;
81 STG::Admins * m_admins;
82 STG::Tariffs * m_tariffs;
84 STG::Services * m_services;
85 STG::Corporations * m_corporations;
89 std::string m_bindAddress;
91 STG::PluginLogger & m_logger;
94 std::string m_errorStr;
96 BASE_PARSER::REGISTRY m_registry;
97 std::deque<STG::Conn *> m_conns;
101 void RegisterParsers();
104 void BuildFDSet(fd_set & fds) const;
106 void HandleEvents(const fd_set & fds);
107 void AcceptConnection();