TTTT Analysis  0.1
container.hpp
1 #ifndef container_hpp
2 #define container_hpp
3 #include "value.hpp"
4 #include "filter.hpp"
5 #include <vector>
6 
7 namespace filval{
9  private:
10  std::string name;
11  std::string desc;
12  std::vector<Filter*> filters;
13  protected:
14  virtual void _fill() = 0;
15  public:
16  GenContainer(const std::string name)
17  :name(name){ }
18  void add_filter(GenValue* filter){
19  filters.push_back(dynamic_cast<Filter*>(filter));
20  }
21  void fill(){
22  for (auto filter : filters){
23  if (!filter->get_value()){
24  return;
25  }
26  }
27  _fill();
28  }
29  void set_description(const std::string& description){
30  desc = description;
31  }
32  const std::string& get_name(){
33  return name;
34  }
35 };
36 typedef std::map<std::string, GenContainer*> ContainerSet;
37 
38 template <typename H>
39 class Container : public GenContainer{
40  protected:
41  H* container;
42  public:
43  Container(H* container, const std::string name)
44  :GenContainer(name),
45  container(container){ }
46  virtual H* get_container(){
47  return container;
48  }
49 
50 };
51 
52 template <typename T>
53 class ContainerVector : public Container<std::vector<T> >{
54  private:
55  Value<T>* value;
56 
57  void _fill(){
58  this->container->push_back(value->get_value());
59  }
60  public:
61  ContainerVector(std::vector<T> *container, Value<T>* value, const std::string name)
62  :Container<std::vector<T> >(container, name),
63  value(value){ }
64  ContainerVector(Value<T>* value, const std::string name)
65  :Container<std::vector<T> >(NULL, name),
66  value(value){
67  this->container = new std::vector<T>();
68  }
69 };
70 
71 }
72 #endif // container_hpp
virtual T & get_value()=0
Calculate, if necessary, and return the value held by this object.
A type-agnostic value.
Definition: value.hpp:64
Definition: container.hpp:53
The namespace containing all filval classes and functions.
Definition: container.hpp:7
Definition: container.hpp:39
Definition: container.hpp:8
A generic value.
Definition: value.hpp:124