virtual int Change(const ADMIN_CONF & ac, const ADMIN * admin) = 0;
virtual const ADMIN * GetSysAdmin() const = 0;
virtual const ADMIN * GetNoAdmin() const = 0;
- virtual bool FindAdmin(const std::string & l, ADMIN ** admin) = 0;
- virtual bool AdminExists(const std::string & login) const = 0;
- virtual bool AdminCorrect(const std::string & login,
- const std::string & password,
- ADMIN ** admin) = 0;
+ virtual bool Find(const std::string & l, ADMIN ** admin) = 0;
+ virtual bool Exists(const std::string & login) const = 0;
+ virtual bool Correct(const std::string & login,
+ const std::string & password,
+ ADMIN ** admin) = 0;
virtual const std::string & GetStrError() const = 0;
+ virtual size_t Count() const = 0;
virtual int OpenSearch() const = 0;
virtual int SearchNext(int, ADMIN_CONF * ac) const = 0;
handle(0)
{
pthread_mutex_init(&mutex, NULL);
-ReadAdmins();
+Read();
}
//-----------------------------------------------------------------------------
int ADMINS_IMPL::Add(const string & login, const ADMIN * admin)
return 0;
}
//-----------------------------------------------------------------------------
-int ADMINS_IMPL::ReadAdmins()
+int ADMINS_IMPL::Read()
{
STG_LOCKER lock(&mutex, __FILE__, __LINE__);
vector<string> adminsList;
}
}
//-----------------------------------------------------------------------------
-bool ADMINS_IMPL::FindAdmin(const string & l, ADMIN ** admin)
+bool ADMINS_IMPL::Find(const string & l, ADMIN ** admin)
{
assert(admin != NULL && "Pointer to admin is not null");
return true;
}
//-----------------------------------------------------------------------------
-bool ADMINS_IMPL::AdminExists(const string & login) const
+bool ADMINS_IMPL::Exists(const string & login) const
{
STG_LOCKER lock(&mutex, __FILE__, __LINE__);
if (data.empty())
return false;
}
//-----------------------------------------------------------------------------
-bool ADMINS_IMPL::AdminCorrect(const string & login, const std::string & password, ADMIN ** admin)
+bool ADMINS_IMPL::Correct(const string & login, const std::string & password, ADMIN ** admin)
{
STG_LOCKER lock(&mutex, __FILE__, __LINE__);
if (data.empty())
#include "stg/locker.h"
#include "stg/store.h"
#include "stg/noncopyable.h"
+#include "stg/logger.h"
#include "admin_impl.h"
class ADMINS_IMPL : private NONCOPYABLE, public ADMINS {
void PrintAdmins() const;
const ADMIN * GetSysAdmin() const { return &stg; }
const ADMIN * GetNoAdmin() const { return &noAdmin; }
- bool FindAdmin(const std::string & l, ADMIN ** admin);
- bool AdminExists(const std::string & login) const;
- bool AdminCorrect(const std::string & login,
- const std::string & password,
- ADMIN ** admin);
+ bool Find(const std::string & l, ADMIN ** admin);
+ bool Exists(const std::string & login) const;
+ bool Correct(const std::string & login,
+ const std::string & password,
+ ADMIN ** admin);
const std::string & GetStrError() const { return strError; }
+ size_t Count() const { return data.size(); }
+
int OpenSearch() const;
int SearchNext(int, ADMIN_CONF * ac) const;
int CloseSearch(int) const;
typedef list<ADMIN_IMPL>::iterator admin_iter;
typedef list<ADMIN_IMPL>::const_iterator const_admin_iter;
- int ReadAdmins();
+ int Read();
ADMIN_IMPL stg;
ADMIN_IMPL noAdmin;