-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnit.hpp
More file actions
50 lines (43 loc) · 1.32 KB
/
Unit.hpp
File metadata and controls
50 lines (43 loc) · 1.32 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
#ifndef ___FCF__PARALLEL__UNIT_HPP___
#define ___FCF__PARALLEL__UNIT_HPP___
#include "macro.hpp"
#include "Arg.hpp"
#include "./Details/FunctionInfo.hpp"
#include "./Details/Function.hpp"
#include "./include.hpp"
#include <memory>
#include <string>
#include <vector>
namespace fcf {
namespace Parallel {
struct Unit {
std::string name;
Union options;
std::string code;
Details::Function function;
std::vector< std::shared_ptr<BaseArg> > args;
inline Unit()
: name("")
, code ("")
, function() {
}
template <typename TFunction>
Unit(const char* a_name, const char* a_options, const char* a_code, TFunction a_function)
: name(a_name)
, code (a_code)
, function(a_function) {
try {
options.parse(a_options);
if (!options.is(UT_MAP)){
options = Union(::fcf::UT_MAP);
}
} catch(std::exception& e) {
throw std::runtime_error(std::string() + "Incorrent format options for '" + a_name + "' parallel unit: " + e.what());
}
Details::FunctionInfo<TFunction>()(args);
}
};
typedef std::shared_ptr<Unit> PUnit;
} // Parallel namespace
} // fcf namespace
#endif // #ifndef ___FCF__PARALLEL__UNIT_HPP___