// // manager_base.h // mc_electron // // Created by Christian Reiling on 17.05.19. // Copyright © 2019 Christian Reiling. All rights reserved. // #ifndef manager_base_h #define manager_base_h #include #include #include "particle.hpp" template class Manager_Base { private: std::vector processes; public: Manager_Base() {}; void add(T* addProc); bool exists(species this_species); T* find(species this_species); }; template inline void Manager_Base::add(T* add) { if (exists(add->get_species())) { std::stringstream ss; ss<<"Manager_Base::add_Process: Dublicate Insert of Process for this Species."; throw MyException (ss.str()); } processes.push_back(add); } template inline bool Manager_Base::exists(species this_species) { for (typename std::vector::iterator itr = processes.begin(); itr!=processes.end(); itr++) { if ((*itr)->get_species() == this_species) { return true; } } return false; } template inline T* Manager_Base::find(species this_species) { for (typename std::vector::iterator itr = processes.begin(); itr!=processes.end(); itr++) { if ((*itr)->get_species() == this_species) { return *itr; } } std::stringstream ss; ss<<"Manager_Base::find(): No Process for this_species implemented.\n"; throw MyException(ss.str()); } #endif /* manager_base_h */