diff options
Diffstat (limited to 'netfs/lib/entCache.h')
-rw-r--r-- | netfs/lib/entCache.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/netfs/lib/entCache.h b/netfs/lib/entCache.h new file mode 100644 index 0000000..c16cd0b --- /dev/null +++ b/netfs/lib/entCache.h @@ -0,0 +1,37 @@ +#ifndef ENTCACHE_H +#define ENTCACHE_H + +#include <pwd.h> +#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(); + + 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 fillCache() const; +}; + +#endif + |