OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
CurlHeaderCache.h
Go to the documentation of this file.
1 #ifndef ossimCurlHeaderCache_HEADER
2 #define ossimCurlHeaderCache_HEADER
4 #include <memory>
5 #include <map>
6 #include <string>
7 #include <utility>
8 #include <mutex> // For std::unique_lock
9 #include <thread>
10 
11 namespace ossim
12 {
14  {
15  public:
17  :m_timestamp(ossimTimer::instance()->tick()),
18  m_filesize(filesize)
19  {
20 
21  }
22 
25  };
26 
28  {
29  public:
30  typedef std::shared_ptr<CurlHeaderCacheNode> Node_t;
31  typedef std::string Key_t;
33  typedef std::map<Key_t, Node_t > CacheType;
34  typedef std::map<TimeIndex_t, Key_t > CacheTimeIndexType;
35 
37  virtual ~CurlHeaderCache();
38  bool getCachedFilesize(const Key_t& key, ossim_int64& filesize)const;
39  void addHeader(const Key_t& key, Node_t& node);
40  void setMaxCacheEntries(ossim_int64 maxEntries);
41  void touchEntry(const Key_t& key);
42 
43  static std::shared_ptr<CurlHeaderCache> instance();
44 
45  protected:
46  void shrinkEntries();
47  void touchEntryProtected(const Key_t& key);
48 
49  static std::shared_ptr<CurlHeaderCache> m_instance;
50  mutable std::mutex m_mutex;
51 
55 
56  };
57 }
58 
59 #endif
unsigned long long Timer_t
Definition: ossimTimer.h:16
static std::shared_ptr< CurlHeaderCache > m_instance
This code was derived from https://gist.github.com/mshockwave.
Definition: Barrier.h:8
static std::shared_ptr< CurlHeaderCache > instance()
void setMaxCacheEntries(ossim_int64 maxEntries)
std::map< TimeIndex_t, Key_t > CacheTimeIndexType
ossimTimer::Timer_t m_timestamp
Timer class is used for measuring elapsed time or time between two points.
Definition: ossimTimer.h:10
ossim_int64 m_maxCacheEntries
std::shared_ptr< CurlHeaderCacheNode > Node_t
void touchEntryProtected(const Key_t &key)
std::map< Key_t, Node_t > CacheType
bool getCachedFilesize(const Key_t &key, ossim_int64 &filesize) const
void touchEntry(const Key_t &key)
CurlHeaderCacheNode(ossim_int64 filesize)
long long ossim_int64
void addHeader(const Key_t &key, Node_t &node)
CacheTimeIndexType m_cacheTime