dataset.hpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef dataset_hpp
  2. #define dataset_hpp
  3. #include "value.hpp"
  4. #include "container.hpp"
  5. namespace filval{
  6. class DataSet{
  7. protected:
  8. ValueSet values;
  9. ContainerSet containers;
  10. virtual bool load_next() = 0;
  11. public:
  12. void process(){
  13. while( load_next() ){
  14. GenValue::reset();
  15. for(auto con : containers)
  16. con.second->fill();
  17. }
  18. }
  19. /* template <typename T> */
  20. /* virtual T* get_field(const std::string& field_name) = 0; */
  21. void add_value(GenValue *value, const std::string& value_name ){
  22. /* Adds a value to the dataset's list of known value objects. Note
  23. * that all new values are automatically kept track of by
  24. * GenValue::values so this is only needed if one wants to recall
  25. * the value by name.
  26. */
  27. values[value_name] = value;
  28. }
  29. GenValue* get_value(std::string value_name){
  30. return values.at(value_name);
  31. }
  32. void add_container(GenContainer *container){
  33. containers[container->get_name()] = container;
  34. }
  35. GenContainer* get_container(std::string container_name){
  36. return containers.at(container_name);
  37. }
  38. };
  39. }
  40. #endif // dataset_hpp