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 : Maxim Mamontov <faust@stargazer.dp.ua>
23 #include "admin_conf.h"
25 #include "stg/common.h"
36 Admin() noexcept : Admin(AdminConf{}) {}
37 Admin(const Priv& priv,
38 const std::string& login,
39 const std::string& password) noexcept
40 : Admin(AdminConf{priv, login, password})
42 explicit Admin(const AdminConf& ac) noexcept : m_conf(ac), m_ip(0) {}
44 Admin(const Admin&) = default;
45 Admin& operator=(const Admin&) = default;
46 Admin(Admin&&) = default;
47 Admin& operator=(Admin&&) = default;
49 Admin& operator=(const AdminConf& ac) noexcept { m_conf = ac; return *this; }
50 bool operator==(const Admin& rhs) const noexcept { return m_conf.login == rhs.m_conf.login; }
51 bool operator!=(const Admin& rhs) const noexcept { return !(*this == rhs); }
52 bool operator<(const Admin& rhs) const noexcept { return m_conf.login < rhs.m_conf.login; }
54 const std::string& password() const { return m_conf.password; }
55 const std::string& login() const { return m_conf.login; }
56 const Priv& priv() const { return m_conf.priv; }
57 uint32_t privAsInt() const { return m_conf.priv.toInt(); }
58 const AdminConf& conf() const { return m_conf; }
59 uint32_t IP() const { return m_ip; }
60 std::string IPStr() const { return inet_ntostring(m_ip); }
61 void setIP(uint32_t v) { m_ip = v; }
62 const std::string logStr() const { return "Admin \'" + m_conf.login + "\', " + IPStr() + ":"; }