diff options
Diffstat (limited to 'src/Common/UserManager.h')
-rw-r--r-- | src/Common/UserManager.h | 80 |
1 files changed, 11 insertions, 69 deletions
diff --git a/src/Common/UserManager.h b/src/Common/UserManager.h index c9b0712..7413970 100644 --- a/src/Common/UserManager.h +++ b/src/Common/UserManager.h @@ -36,6 +36,7 @@ namespace Common { class Application; class UserBackend; +class UserCache; class UserManager : boost::noncopyable { private: @@ -45,84 +46,25 @@ class UserManager : boost::noncopyable { bool operator() (boost::shared_ptr<UserBackend> b1, boost::shared_ptr<UserBackend> b2); }; - std::set<boost::shared_ptr<UserBackend>, Compare> backends; + typedef std::map<boost::shared_ptr<UserBackend>, boost::shared_ptr<UserBackend>, Compare> BackendMap; - boost::shared_mutex backendMutex; - boost::shared_mutex mutex; - - bool caching; - - boost::shared_ptr<const std::map<unsigned long, UserInfo> > users; - boost::shared_ptr<const std::map<std::string, unsigned long> > userNames; - boost::shared_ptr<Core::Exception> userException; + BackendMap backends; - boost::shared_ptr<const std::map<unsigned long, GroupInfo> > groups; - boost::shared_ptr<const std::map<std::string, unsigned long> > groupNames; - boost::shared_ptr<Core::Exception> groupException; - - boost::shared_ptr<const std::multimap<unsigned long, unsigned long> > userGroups; - boost::shared_ptr<const std::multimap<unsigned long, unsigned long> > groupUsers; - boost::shared_ptr<Core::Exception> userGroupException; + boost::shared_mutex mutex; - UserManager() : caching(false) {} + UserManager() {} public: void registerBackend(boost::shared_ptr<UserBackend> backend) { - { - boost::lock_guard<boost::shared_mutex> lock(backendMutex); - backends.insert(backend); - } - - update(); - } - - void unregisterBackend(boost::shared_ptr<UserBackend> backend) { - { - boost::lock_guard<boost::shared_mutex> lock(backendMutex); - backends.erase(backend); - } - - update(); + boost::lock_guard<boost::shared_mutex> lock(mutex); + backends.insert(std::make_pair(backend, backend)); } - bool isCaching() { - boost::shared_lock<boost::shared_mutex> lock(mutex); - return caching; - } - - void setCaching(bool cache) { - { - boost::lock_guard<boost::shared_mutex> lock(mutex); - caching = cache; - } - - update(); - } - - void update(bool refresh = false) { - { - boost::lock_guard<boost::shared_mutex> lock(mutex); + void registerBackendCached(boost::shared_ptr<UserBackend> backend); - if(!caching) - return; - - users.reset(); - userNames.reset(); - userException.reset(); - - groups.reset(); - groupNames.reset(); - groupException.reset(); - - userGroups.reset(); - groupUsers.reset(); - userGroupException.reset(); - } - - if(refresh) { - getUserList(); - getGroupList(); - } + void unregisterBackend(boost::shared_ptr<UserBackend> backend) { + boost::lock_guard<boost::shared_mutex> lock(mutex); + backends.erase(backend); } boost::shared_ptr<const std::map<unsigned long, UserInfo> > getUserList() throw(Core::Exception); |