* [locomotiv] Use macro to iterate supported Nodes
This commit introduces list of supported Nodes for execution, and use
them with macro to iterate and do same thing through Nodes.
Signed-off-by: Cheongyo Bahk <ch.bahk@samsung.com>
* clang-format off for comment indentation
--- /dev/null
+#ifndef NODE
+#error Define NODE first
+#endif // NODE
+
+// NODE(Name) : alphabetic order please
+
+NODE(Pull)
+NODE(Push)
// TODO Use visitor pattern of loco when available
void NodeExecution::run(loco::Node *node)
{
- if (as<loco::Pull>(node))
- {
- execute(as<loco::Pull>(node));
- return;
- }
-
- if (as<loco::Push>(node))
- {
- execute(as<loco::Push>(node));
- return;
+#define NODE(Name) \
+ if (as<loco::Name>(node)) \
+ { \
+ execute(as<loco::Name>(node)); \
+ return; \
}
+#include "Node.lst"
+#undef NODE
throw std::runtime_error("Not supported loco::Node type");
}
return dynamic_cast<Derived *>(node);
}
+// clang-format off
/**
* @brief Calculate for one specified node and update its result as NodeData.
* Abort program when its ingredients are not ready or not supported.
*
* @note Definitions of overloaded execute() are in 'Node/' directory
*/
- void execute(loco::Pull *);
- void execute(loco::Push *);
+// clang-format on
+#define NODE(Name) void execute(loco::Name *);
+#include "Node.lst"
+#undef NODE
};
} // namespace locomotiv