From e496319a2820abe0ec1d2e37c915ded3f314f5cf Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Thu, 18 Sep 2014 22:43:34 +0300 Subject: [PATCH 1/1] Added a function to check user existance. --- include/stg/users.h | 1 + projects/stargazer/users_impl.cpp | 7 +++++++ projects/stargazer/users_impl.h | 2 ++ 3 files changed, 10 insertions(+) diff --git a/include/stg/users.h b/include/stg/users.h index 9f516aef..3fb951e0 100644 --- a/include/stg/users.h +++ b/include/stg/users.h @@ -33,6 +33,7 @@ public: virtual ~USERS() {} virtual int FindByName(const std::string & login, USER_PTR * user) = 0; virtual int FindByName(const std::string & login, CONST_USER_PTR * user) const = 0; + virtual bool Exists(const std::string & login) const = 0; virtual bool TariffInUse(const std::string & tariffName) const = 0; diff --git a/projects/stargazer/users_impl.cpp b/projects/stargazer/users_impl.cpp index d66456af..3dd7638b 100644 --- a/projects/stargazer/users_impl.cpp +++ b/projects/stargazer/users_impl.cpp @@ -126,6 +126,13 @@ if (FindByNameNonLock(login, &u)) return 0; } //----------------------------------------------------------------------------- +bool USERS_IMPL::Exists(const std::string & login) const +{ +STG_LOCKER lock(&mutex); +const std::map::const_iterator iter(loginIndex.find(login)); +return iter != loginIndex.end(); +} +//----------------------------------------------------------------------------- bool USERS_IMPL::TariffInUse(const std::string & tariffName) const { STG_LOCKER lock(&mutex); diff --git a/projects/stargazer/users_impl.h b/projects/stargazer/users_impl.h index 43065bde..a8f8d559 100644 --- a/projects/stargazer/users_impl.h +++ b/projects/stargazer/users_impl.h @@ -77,6 +77,8 @@ public: int FindByName(const std::string & login, USER_PTR * user); int FindByName(const std::string & login, CONST_USER_PTR * user) const; + bool Exists(const std::string & login) const; + bool TariffInUse(const std::string & tariffName) const; void AddNotifierUserAdd(NOTIFIER_BASE *); -- 2.44.2