Files
katrin-plasma/src/mc_electron/manager_base.h
T
Christian 578d673b65 Moved serial mode to target mcelecron_serial.
Implemented parallelization with mpi.
2019-07-18 14:02:19 +02:00

65 lines
1.4 KiB
C++

//
// 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 <vector>
#include <sstream>
#include "particle.hpp"
template <class T>
class Manager_Base {
private:
std::vector<T*> processes;
public:
Manager_Base() {};
void add(T* addProc);
bool exists(species this_species);
T* find(species this_species);
};
template <class T>
inline void Manager_Base<T>::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 <class T>
inline bool Manager_Base<T>::exists(species this_species) {
for (typename std::vector<T*>::iterator itr = processes.begin(); itr!=processes.end(); itr++) {
if ((*itr)->get_species() == this_species) {
return true;
}
}
return false;
}
template <class T>
inline T* Manager_Base<T>::find(species this_species) {
for (typename std::vector<T*>::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 */