This example shows how to import from an existing algorithm
#include <complex>
#define STATE_MACHINE_CPP_EXAMPLE_FORLOOP_H
#include "../1_ForLoop/example_ForLoop_main.cpp"
class PowerLoop final :
public Algorithm::Builder {
public:
struct Attributes {
};
static AttributeTree<Layer<ForLoop::Attributes, PowerLoop::Attributes>>*
create_attributes(
int max_iteration,
unsigned int power) {
return new AttributeTree<Layer<ForLoop::Attributes, PowerLoop::Attributes>>(
);
}
std::cout << for_loop_attributes.iteration <<
'^' << power_loop_attributes.
power
<<
" = " << std::pow(for_loop_attributes.iteration, power_loop_attributes.
power)
<< std::endl;
}
void build(States &states, Transitions &transitions, Layers &layers)
override {
import<ForLoop>(states, transitions, layers);
}
};
int main(
int argc,
const char** argv) {
Algorithm::Instance algorithm;
Algorithm::build<PowerLoop>(algorithm);
auto context = Context::create<PowerLoop>(3, 2);
}