#ifndef ENTCACHE_H #define ENTCACHE_H #include #include #include #include #include #include #include #include class User : public IceUtil::Shared { public: User(uid_t, const std::string &, gid_t); uid_t id; std::string name; gid_t group; }; class Group : public IceUtil::Shared { public: Group(gid_t, const std::string &); bool hasMember(uid_t) const; gid_t id; std::string name; std::set members; }; template class EntCache { public: typedef decltype(entry_t::id) id_t; typedef decltype(entry_t::name) name_t; typedef IceUtil::Handle entry_ptr; virtual ~EntCache(); const id_t & getID(const name_t & ) const; const name_t & getName(const id_t &) const; template entry_ptr getEntry(const key_t &) const; static const EntCache instance; protected: EntCache(); void fillCache() const; template entry_ptr getEntryNoFill(const key_t &) const; typedef boost::multi_index::multi_index_container, boost::multi_index::indexed_by< boost::multi_index::ordered_unique< boost::multi_index::tag, BOOST_MULTI_INDEX_MEMBER(entry_t, const id_t, id)>, boost::multi_index::ordered_unique< boost::multi_index::tag, BOOST_MULTI_INDEX_MEMBER(entry_t, const std::string, name)> > > IDs; mutable IDs idcache; mutable boost::shared_mutex lock; mutable time_t fillTime; }; typedef EntCache UserEntCache; typedef EntCache GroupEntCache; #endif