65 lines
1.4 KiB
C++
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 */
|