Add shared tasks to Target.hpp
This commit is contained in:
parent
a0e185adb5
commit
ab01c1bcb2
|
@ -66,12 +66,19 @@ protected:
|
|||
} else output << openCharacters << view << closeCharacters << '\n';
|
||||
}
|
||||
typedef function<void (const ParseTree& parsedTree, unsigned int& index)> task;
|
||||
#define make_task(X, L) make_pair(type_index(typeid(X)), [this](const ParseTree& parsedTree, unsigned int& index) { const X& parseComponent = pointerAs<X>(parsedTree[index]); L })
|
||||
#define make_task_base(type, captures, function_body) make_pair(type_index(typeid(type)), [captures](const ParseTree& parsedTree, unsigned int& index) { const type& parseComponent = pointerAs<type>(parsedTree[index]); function_body })
|
||||
#define make_task(T, F) make_task_base(T, this, F)
|
||||
typedef unordered_map<type_index, optional<task>> unordered_task_map;
|
||||
virtual unordered_task_map getTaskMap() = 0;
|
||||
public:
|
||||
unordered_task_map& getTaskMapInstance() {
|
||||
const unordered_task_map& getTaskMapInstance() {
|
||||
static unordered_task_map staticMap = getTaskMap();
|
||||
// Default / Shared tasks:
|
||||
staticMap.merge(unordered_task_map({
|
||||
make_task(StandardComponents::Reference,
|
||||
output << parseComponent.name;
|
||||
)
|
||||
}));
|
||||
return staticMap;
|
||||
};
|
||||
static shared_ptr<Target> forName(string_view name, bool newLines);
|
||||
|
|
Loading…
Reference in New Issue