source: filezilla/trunk/fuentes/src/engine/pathcache.h @ 3185

Last change on this file since 3185 was 3185, checked in by jrpelegrina, 3 years ago

Update new version: 3.15.02

File size: 1.7 KB
Line 
1#ifndef __PATHCACHE_H__
2#define __PATHCACHE_H__
3
4#include <libfilezilla/mutex.hpp>
5
6class CPathCache final
7{
8public:
9        CPathCache();
10        ~CPathCache();
11
12        CPathCache(CPathCache const&) = delete;
13        CPathCache& operator=(CPathCache const&) = delete;
14
15        // The source argument should be a canonicalized path already if subdir is non-empty
16        void Store(CServer const& server, CServerPath const& target, CServerPath const& source, wxString const& subdir = wxString());
17
18        // The source argument should be a canonicalized path already if subdir is non-empty happen
19        CServerPath Lookup(CServer const& server, CServerPath const& source, wxString const& subdir = wxString());
20
21        void InvalidateServer(CServer const& server);
22
23        // Invalidate path
24        void InvalidatePath(CServer const& server, CServerPath const& path, wxString const& subdir = wxString());
25
26        void Clear();
27
28protected:
29        class CSourcePath
30        {
31        public:
32                CServerPath source;
33                wxString subdir;
34
35                bool operator<(CSourcePath const& op) const
36                {
37                        return std::tie(subdir, source) < std::tie(op.subdir, op.source);
38                }
39        };
40
41        fz::mutex mutex_;
42
43        typedef std::map<CSourcePath, CServerPath> tServerCache;
44        typedef tServerCache::iterator tServerCacheIterator;
45        typedef tServerCache::const_iterator tServerCacheConstIterator;
46        typedef std::map<CServer, tServerCache> tCache;
47        tCache m_cache;
48        typedef tCache::iterator tCacheIterator;
49        typedef tCache::const_iterator tCacheConstIterator;
50
51        CServerPath Lookup(tServerCache const& serverCache, CServerPath const& source, wxString const& subdir);
52        void InvalidatePath(tServerCache & serverCache, CServerPath const& path, wxString const& subdir = wxString());
53
54        int m_hits{};
55        int m_misses{};
56
57};
58
59#endif //__PATHCACHE_H__
Note: See TracBrowser for help on using the repository browser.