Plugin Interface
A plugin approach allows to introduce a unified interface on top of arbitrary tools. Our approach uses common dynamic polymorphism to implement a unified interface. We follow a three-step interface model, allowing to implement specific code for initialization, execution, and finalization, as depicted in the following.
#include "viennax/core/plugin.hpp" #define PLUGIN_NAME Dummy9 namespace viennax { struct PLUGIN_NAME : public plugin { INIT_VIENNAX_PLUGIN void init() { ... } bool execute(std::size_t call) { ... return true; } void finalize() { ... } }; FINALIZE_VIENNAX_PLUGIN }
Each plugin is implemented in its own class, and to honor the ViennaX interfaces, it has to derive from the base class (Line 7).
Macros take care of boiler plate code generation (Lines 9,24).
The initialization method is used to prepare the execution, such as setting up data dependencies and generating datastructures, which can be kept in the plugin's state (Lines 11-13). The user is supposed to place the actual implementation into the execution region (Lines 15-18). A dedicated finalization phase allows the plugin to perform a 'clean up', for instance, deallocate dynamically created datastructures (Lines 20-22).