diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2020-04-04 12:52:40 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2020-04-04 12:52:40 +0100 |
commit | 2fd277d0af2ed15098e2a92cca9e60f3c60d7c2e (patch) | |
tree | 9e1f5182f943bb574da640d0260b16a2ab14579c | |
parent | Move boost multi index out of header (diff) | |
download | netfs-2fd277d0af2ed15098e2a92cca9e60f3c60d7c2e.tar.bz2 netfs-2fd277d0af2ed15098e2a92cca9e60f3c60d7c2e.tar.xz netfs-2fd277d0af2ed15098e2a92cca9e60f3c60d7c2e.zip |
Fix templateness of EntryResolver
name wasn't templatable
-rw-r--r-- | netfs/ice/entryResolver.h | 7 | ||||
-rw-r--r-- | netfs/ice/typeConverter.cpp | 2 | ||||
-rw-r--r-- | netfs/ice/typeConverter.h | 8 | ||||
-rw-r--r-- | netfs/lib/entCache.cpp | 16 | ||||
-rw-r--r-- | netfs/lib/entCache.h | 2 |
5 files changed, 15 insertions, 20 deletions
diff --git a/netfs/ice/entryResolver.h b/netfs/ice/entryResolver.h index b5efbc3..cbdc789 100644 --- a/netfs/ice/entryResolver.h +++ b/netfs/ice/entryResolver.h @@ -1,16 +1,11 @@ #ifndef NETFS_ENTRYRESOLVER_H #define NETFS_ENTRYRESOLVER_H -#include <string> -#include <stdlib.h> - -template <class entry_t> +template <typename id_t, typename name_t> class EntryResolver { public: virtual ~EntryResolver() = default; - using name_t = std::string; - virtual void getID(const name_t &, id_t *) const = 0; virtual void getName(const id_t &, name_t *) const = 0; }; diff --git a/netfs/ice/typeConverter.cpp b/netfs/ice/typeConverter.cpp index 0e3ce7f..8e75326 100644 --- a/netfs/ice/typeConverter.cpp +++ b/netfs/ice/typeConverter.cpp @@ -1,7 +1,7 @@ #include "typeConverter.h" #include <boost/numeric/conversion/cast.hpp> -EntryTypeConverter::EntryTypeConverter(const EntryResolver<uid_t> & u, const EntryResolver<gid_t> & g) : +EntryTypeConverter::EntryTypeConverter(const UserLookup & u, const GroupLookup & g) : userLookup(u), groupLookup(g) { diff --git a/netfs/ice/typeConverter.h b/netfs/ice/typeConverter.h index b8d6fcd..fedd204 100644 --- a/netfs/ice/typeConverter.h +++ b/netfs/ice/typeConverter.h @@ -16,15 +16,17 @@ class DLL_PUBLIC TypeConverter { class DLL_PUBLIC EntryTypeConverter : public TypeConverter { public: - EntryTypeConverter(const EntryResolver<uid_t> &, const EntryResolver<gid_t> &); + using UserLookup = EntryResolver<uid_t, std::string>; + using GroupLookup = EntryResolver<gid_t, std::string>; + EntryTypeConverter(const UserLookup &, const GroupLookup &); // Attributes struct stat convert(const NetFS::Attr &) const; NetFS::Attr convert(const struct stat &) const; protected: - const EntryResolver<uid_t> & userLookup; - const EntryResolver<gid_t> & groupLookup; + const UserLookup & userLookup; + const GroupLookup & groupLookup; }; #endif diff --git a/netfs/lib/entCache.cpp b/netfs/lib/entCache.cpp index 9b78dff..d62f4bf 100644 --- a/netfs/lib/entCache.cpp +++ b/netfs/lib/entCache.cpp @@ -54,18 +54,16 @@ template<class key_t> typename EntCache<entry_t>::entry_ptr EntCache<entry_t>::getEntry(const key_t & key) const { - typename EntCache<entry_t>::entry_ptr ent; if (fillTime + 60 > time(nullptr)) { - ent = getEntryNoFill<key_t>(key); - } - if (!ent) { - fillCache(); - ent = getEntryNoFill<key_t>(key); + if (auto ent = getEntryNoFill<key_t>(key)) { + return ent; + } } - if (!ent) { - throw NetFS::SystemError(EPERM); + fillCache(); + if (auto ent = getEntryNoFill<key_t>(key)) { + return ent; } - return ent; + throw NetFS::SystemError(EPERM); } template<class entry_t> diff --git a/netfs/lib/entCache.h b/netfs/lib/entCache.h index 73cd36d..9facdb3 100644 --- a/netfs/lib/entCache.h +++ b/netfs/lib/entCache.h @@ -26,7 +26,7 @@ class Group { }; template<class entry_t> -class EntCache : public EntryResolver<decltype(entry_t::id)> { +class EntCache : public EntryResolver<decltype(entry_t::id), decltype(entry_t::name)> { public: EntCache(); ~EntCache() override; |