diff options
Diffstat (limited to 'netfs/entCache.h')
-rw-r--r-- | netfs/entCache.h | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/netfs/entCache.h b/netfs/entCache.h index fc8ab08..c16cd0b 100644 --- a/netfs/entCache.h +++ b/netfs/entCache.h @@ -5,24 +5,32 @@ #include <grp.h> #include <string> #include <boost/bimap.hpp> +#include <boost/thread/shared_mutex.hpp> +template<class id_t, class name_t> class EntCache { public: EntCache(); virtual ~EntCache(); - uid_t getUID(const std::string & ) const; - gid_t getGID(const std::string & ) const; - const std::string & getUName(uid_t) const; - const std::string & getGName(gid_t) const; + const id_t & getID(const name_t & ) const; + const name_t & getName(const id_t &) const; + protected: + virtual void fillCache() const = 0; + typedef boost::bimap<id_t, name_t> IDs; + mutable IDs idcache; + mutable boost::shared_mutex lock; +}; + +class UserEntCache : public EntCache<uid_t, std::string> { + private: + void fillCache() const; +}; + +class GroupEntCache : public EntCache<gid_t, std::string> { private: - void makeuidCache() const; - void makegidCache() const; - typedef boost::bimap<uid_t, std::string> UIDs; - typedef boost::bimap<gid_t, std::string> GIDs; - mutable UIDs uidcache; - mutable GIDs gidcache; + void fillCache() const; }; #endif |