#ifndef container_hpp #define container_hpp #include "value.hpp" #include "filter.hpp" #include namespace filval{ class GenContainer{ private: std::string name; std::string desc; std::vector filters; protected: virtual void _fill() = 0; public: GenContainer(const std::string name, const std::string& desc) :name(name),desc(desc) { } GenContainer(const std::string name) :GenContainer(name,"N/A"){ } void add_filter(GenValue* filter){ filters.push_back(dynamic_cast(filter)); } void fill(){ for (auto filter : filters){ if (!filter->get_value()) return; } _fill(); } void set_description(const std::string& description){ desc = description; } const std::string& get_name(){ return name; } }; typedef std::map ContainerSet; template class Container : public GenContainer{ protected: H* container; public: Container(const std::string& name, H* container) :GenContainer(name), container(container){ } virtual H* get_container(){ return container; } }; template class ContainerVector : public Container >{ private: Value* value; void _fill(){ this->container->push_back(value->get_value()); } public: ContainerVector(const std::string& name, std::vector *container, Value* value) :Container >(name, container), value(value){ } ContainerVector(const std::string& name, Value* value) :Container >(name, nullptr), value(value){ this->container = new std::vector(); } }; template class ContainerMean : public Container{ private: Value* value; int count; T sum; void _fill(){ count++; sum += value->get_value(); } public: ContainerMean(const std::string& name, Value* value) :Container >(name, nullptr), value(value){ this->container = new T(); } T* get_container(){ *(this->container) = sum/count; return (this->container); } }; } #endif // container_hpp