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
22 * Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
27 #include "stg/admin.h"
28 #include "stg/admin_conf.h"
36 class AdminImpl : public Admin {
38 AdminImpl() noexcept : ip(0) {}
40 explicit AdminImpl(const AdminConf& ac) noexcept : conf(ac), ip(0) {}
41 AdminImpl(const Priv& priv,
42 const std::string& login,
43 const std::string& password) noexcept
44 : conf(priv, login, password), ip(0)
47 AdminImpl(const AdminImpl&) = default;
48 AdminImpl& operator=(const AdminImpl&) = default;
49 AdminImpl(AdminImpl&&) = default;
50 AdminImpl& operator=(AdminImpl&&) = default;
52 AdminImpl& operator=(const AdminConf& ac) noexcept { conf = ac; return *this; }
53 bool operator==(const AdminImpl& rhs) const noexcept { return conf.login == rhs.conf.login; }
54 bool operator!=(const AdminImpl& rhs) const noexcept { return !(*this == rhs); }
55 bool operator<(const AdminImpl& rhs) const noexcept { return conf.login < rhs.conf.login; }
56 //bool operator<=(const AdminImpl & rhs) const;
58 const std::string& GetPassword() const override { return conf.password; }
59 const std::string& GetLogin() const override { return conf.login; }
60 const Priv* GetPriv() const override { return &conf.priv; }
61 uint32_t GetPrivAsInt() const override { return conf.priv.toInt(); }
62 const AdminConf& GetConf() const override { return conf; }
64 uint32_t GetIP() const override { return ip; }
65 std::string GetIPStr() const override;
66 void SetIP(uint32_t v) override { ip = v; }
67 const std::string GetLogStr() const override;