-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegistrator.hpp
More file actions
56 lines (42 loc) · 1.58 KB
/
Registrator.hpp
File metadata and controls
56 lines (42 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef ___FCF__PARALLEL__DETAILS__REGISTRATOR_HPP___
#define ___FCF__PARALLEL__DETAILS__REGISTRATOR_HPP___
#include <stdexcept>
#include <map>
#include "macro.hpp"
#define FCF_PARALLEL_INCLUDE_LIBRARY fcfBasis
#define FCF_PARALLEL_INCLUDE_FILE nativeType.hpp
#include "include.hpp"
#include "Unit.hpp"
namespace fcf {
namespace Parallel {
struct Units {
typedef std::map<std::string, PUnit> units_type;
units_type units;
};
namespace Details {
FCF_PARALLEL_DELC_EXTERN FCF_PARALLEL_DECL_EXPORT Units __fcf_parallel_units;
} // Details namespace
struct FCF_PARALLEL_DECL_EXPORT Registrator {
inline Registrator(){}
template<typename TFunction>
Registrator(const char* a_name, const char* a_options, const char* a_code, TFunction a_func) {
add(a_name, a_options, a_code, a_func);
}
template<typename TFunction>
void add(const char* a_name, const char* a_options, const char* a_code, TFunction a_func) {
Details::__fcf_parallel_units.units[a_name] = PUnit(new Unit{a_name, a_options, a_code, a_func});
}
PUnit get(const char* a_name);
};
#ifdef FCF_PARALLEL_IMPLEMENTATION
PUnit Registrator::get(const char* a_name){
Units::units_type::iterator it = Details::__fcf_parallel_units.units.find(a_name);
if (it == Details::__fcf_parallel_units.units.end()){
throw std::runtime_error("Unit name not found");
}
return it->second;
}
#endif
} // Parallel namespace
} // fcf namespace
#endif