OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
S3HeaderCache.h
Go to the documentation of this file.
1 #ifndef ossimS3HeaderCache_HEADER
2 #define ossimS3HeaderCache_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<S3HeaderCacheNode> 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 
36  S3HeaderCache();
37  virtual ~S3HeaderCache();
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  static std::shared_ptr<S3HeaderCache> instance();
42 
43  protected:
44  void shrinkEntries();
45 
46  static std::shared_ptr<S3HeaderCache> m_instance;
47  mutable std::mutex m_mutex;
48 
52 
53  };
54 }
55 
56 #endif
ossim_int64 m_maxCacheEntries
Definition: S3HeaderCache.h:51
ossim_int64 TimeIndex_t
Definition: S3HeaderCache.h:32
std::shared_ptr< S3HeaderCacheNode > Node_t
Definition: S3HeaderCache.h:30
unsigned long long Timer_t
Definition: ossimTimer.h:16
void addHeader(const Key_t &key, Node_t &node)
S3HeaderCacheNode(ossim_int64 filesize)
Definition: S3HeaderCache.h:16
static std::shared_ptr< S3HeaderCache > m_instance
Definition: S3HeaderCache.h:46
This code was derived from https://gist.github.com/mshockwave.
Definition: Barrier.h:8
void setMaxCacheEntries(ossim_int64 maxEntries)
std::map< Key_t, Node_t > CacheType
Definition: S3HeaderCache.h:33
CacheTimeIndexType m_cacheTime
Definition: S3HeaderCache.h:50
bool getCachedFilesize(const Key_t &key, ossim_int64 &filesize) const
Timer class is used for measuring elapsed time or time between two points.
Definition: ossimTimer.h:10
std::map< TimeIndex_t, Key_t > CacheTimeIndexType
Definition: S3HeaderCache.h:34
static std::shared_ptr< S3HeaderCache > instance()
long long ossim_int64
ossimTimer::Timer_t m_timestamp
Definition: S3HeaderCache.h:23