dataset.hpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #ifndef dataset_hpp
  2. #define dataset_hpp
  3. #include <iostream>
  4. #include "value.hpp"
  5. #include "container.hpp"
  6. namespace filval{
  7. class DataSet{
  8. private:
  9. void summary(){
  10. GenValue::summary();
  11. }
  12. protected:
  13. ContainerSet containers;
  14. virtual bool load_next() = 0;
  15. virtual int get_events() = 0;
  16. virtual int get_current_event() = 0;
  17. public:
  18. void process(){
  19. int events, current_event;
  20. summary();
  21. events = get_events();
  22. std::cout << std::endl;
  23. while( load_next() ){
  24. current_event = get_current_event();
  25. std::cout << "\rprocessing event: " << current_event+1 << "/" << events << std::flush;
  26. GenValue::reset();
  27. for(auto con : containers){
  28. /* std::cout << std::endl << "Filling container: " << con.first; */
  29. con.second->fill();
  30. }
  31. /* std::cout << std::endl; */
  32. }
  33. std::cout << " Finished!" << std::endl;
  34. }
  35. void add_container(GenContainer *container){
  36. containers[container->get_name()] = container;
  37. }
  38. GenContainer* get_container(std::string container_name){
  39. return containers.at(container_name);
  40. }
  41. };
  42. }
  43. #endif // dataset_hpp