summaryrefslogtreecommitdiff
path: root/netfs/lib/entCache.h
blob: c16cd0b3c7854c291fbee4d1fcdd53a76e1ead50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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