TECA
The Toolkit for Extreme Climate Analysis
teca_indexed_dataset_cache.h
1 #ifndef teca_indexed_dataset_cache_h
2 #define teca_indexed_dataset_cache_h
3 
4 #include "teca_shared_object.h"
5 #include "teca_algorithm.h"
6 #include "teca_metadata.h"
7 
8 #include <string>
9 #include <vector>
10 
11 TECA_SHARED_OBJECT_FORWARD_DECL(teca_indexed_dataset_cache)
12 
13 /// Caches N datasets such that repeated requests for the same dataset are served from the cache
14 /**
15  * A cache storing up to N datasets. Datasets are identified using their
16  * request index. Repeated requests for the same dataset (ie same index) are
17  * served from the cache. When more than N unique datasets have been requested
18  * the cache is modified such that the least recently used dataset is replaced.
19  */
21 {
22 public:
23  TECA_ALGORITHM_STATIC_NEW(teca_indexed_dataset_cache)
24  TECA_ALGORITHM_DELETE_COPY_ASSIGN(teca_indexed_dataset_cache)
25  TECA_ALGORITHM_CLASS_NAME(teca_indexed_dataset_cache)
27 
28  // report/initialize to/from Boost program options
29  // objects.
30  TECA_GET_ALGORITHM_PROPERTIES_DESCRIPTION()
31  TECA_SET_ALGORITHM_PROPERTIES()
32 
33  /** @name max_cache_size
34  * Set the max number of datasets to cache.
35  */
36  ///@{
37  TECA_ALGORITHM_PROPERTY(unsigned long, max_cache_size)
38  ///@}
39 
40  /// clear any cached data.
41  void clear_cache();
42 
43 protected:
45 
46 private:
47 
48  std::vector<teca_metadata> get_upstream_request(
49  unsigned int port,
50  const std::vector<teca_metadata> &input_md,
51  const teca_metadata &request) override;
52 
53  const_p_teca_dataset execute(
54  unsigned int port,
55  const std::vector<const_p_teca_dataset> &input_data,
56  const teca_metadata &request) override;
57 
58 private:
59  unsigned long max_cache_size;
60 
61  struct internals_t;
62  internals_t *internals;
63 };
64 
65 #endif
teca_metadata
A generic container for meta data in the form of name=value pairs.
Definition: teca_metadata.h:18
teca_shared_object.h
teca_indexed_dataset_cache
Caches N datasets such that repeated requests for the same dataset are served from the cache.
Definition: teca_indexed_dataset_cache.h:20
teca_algorithm
The interface to TECA pipeline architecture.
Definition: teca_algorithm.h:237