Flow123d  jenkins-Flow123d-linux-release-multijob-198
element_data_cache.hh
Go to the documentation of this file.
1 /*
2  * element_data_cache.hh
3  *
4  * Created on: Jan 28, 2013
5  * Author: jb
6  */
7 
8 #ifndef ELEMENT_DATA_CACHE_HH_
9 #define ELEMENT_DATA_CACHE_HH_
10 
11 #include <vector>
12 #include <string>
13 #include <memory>
14 
15 
17 public:
18  /// Constructor.
20  : time_(-std::numeric_limits<double>::infinity()),
21  quantity_name_("") {}
22 
23  /// Getter for time of cache
24  double get_time()
25  { return time_; }
26 
27  /// Getter for quantity name of cache
28  std::string get_quantity_name()
29  { return quantity_name_; }
30 
31  /// Check if cache stored actual data
32  bool is_actual(double time, std::string quantity_name) {
33  return (time_ == time) && (quantity_name_ == quantity_name);
34  }
35 
36 protected:
37  /// time step stored in cache
38  double time_;
39  /// name of quantity stored in cache
40  std::string quantity_name_;
41 };
42 
43 
44 template <typename T>
46 public:
47  typedef std::shared_ptr< std::vector<T> > ComponentDataPtr;
49 
50  /// Constructor.
51  ElementDataCache(double time, std::string quantity_name, CacheData data)
52  : data_(data) {
53  this->time_ = time;
54  this->quantity_name_ = quantity_name;
55  }
56 
57  /// Return vector of element data for get component.
58  ComponentDataPtr get_component_data(unsigned int component_idx) {
59  ASSERT(component_idx < data_.size(), "Index of component is out of range.\n");
60  return data_[component_idx];
61  }
62 
63 protected:
64  /**
65  * Table of element data.
66  *
67  * For every components contains vector of element data.
68  */
70 
71 };
72 
73 #endif /* ELEMENT_DATA_CACHE_HH_ */
double time_
time step stored in cache
std::shared_ptr< std::vector< T > > ComponentDataPtr
ComponentDataPtr get_component_data(unsigned int component_idx)
Return vector of element data for get component.
std::vector< ComponentDataPtr > CacheData
double get_time()
Getter for time of cache.
ElementDataCache(double time, std::string quantity_name, CacheData data)
Constructor.
std::string quantity_name_
name of quantity stored in cache
#define ASSERT(...)
Definition: global_defs.h:121
bool is_actual(double time, std::string quantity_name)
Check if cache stored actual data.
ElementDataCacheBase()
Constructor.
std::string get_quantity_name()
Getter for quantity name of cache.