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 "admin_impl.h"
29 #include "stg/admins.h"
30 #include "stg/admin.h"
31 #include "stg/locker.h"
32 #include "stg/store.h"
33 #include "stg/noncopyable.h"
34 #include "stg/logger.h"
45 class AdminsImpl : public Admins {
47 explicit AdminsImpl(Store * st);
48 virtual ~AdminsImpl() {}
50 int Add(const std::string & login, const Admin * admin);
51 int Del(const std::string & login, const Admin * admin);
52 int Change(const AdminConf & ac, const Admin * admin);
53 const Admin * GetSysAdmin() const { return &stg; }
54 const Admin * GetNoAdmin() const { return &noAdmin; }
55 bool Find(const std::string & l, Admin ** admin);
56 bool Exists(const std::string & login) const;
57 bool Correct(const std::string & login,
58 const std::string & password,
60 const std::string & GetStrError() const { return strError; }
62 size_t Count() const { return data.size(); }
64 int OpenSearch() const;
65 int SearchNext(int, AdminConf * ac) const;
66 int CloseSearch(int) const;
69 AdminsImpl(const AdminsImpl & rvalue);
70 AdminsImpl & operator=(const AdminsImpl & rvalue);
72 typedef std::vector<AdminImpl>::iterator admin_iter;
73 typedef std::vector<AdminImpl>::const_iterator const_admin_iter;
79 std::vector<AdminImpl> data;
81 Logger & WriteServLog;
82 mutable std::map<int, const_admin_iter> searchDescriptors;
83 mutable unsigned int handle;
84 mutable pthread_mutex_t mutex;