- //--------------------------------------------------------------------------
- //
- // template class NeuroneFunction0
- //
- //--------------------------------------------------------------------------
- template <class Func, class Ret>
- class NeuroneFunction0 : public Neurone {
- Func func;
- Str def;
- void onValueGet() {
- getOutput(0).setValue(TypeToVariable <Ret> (func()).value);
- }
- public:
- NeuroneFunction0(const char *def_, Func func_, const char *ret_name) {
- def = def_;
- func = func_;
- Output *output = new Output(this);
- output->getVariable().setType <Ret> ();
- addOutput(ret_name, output);
- output->setOnGetValueAction(Common::Action::create(this, &NeuroneFunction0 <Func, Ret> ::onValueGet));
- }
- //
- virtual const char *getType() const {
- return def;
- }
- Neurone *clone() const {
- return new NeuroneFunction0 <Func, Ret> (def, func, getOutputName(0));
- }
- };
- template <class Func>
- class NeuroneFunction0 <Func, void> : public Neurone {
- Anandamide::Action *in;
- Anandamide::Event *out;
- Func func;
- Str def;
- public:
- NeuroneFunction0(const char *def_, Func func_, const char *ret_name) {
- def = def_;
- func = func_;
- in = createAction(this, &NeuroneFunction0 <Func> ::run);
- out = new Event();
- addAction("in", in);
- addEvent("out", out);
- }
- //
- virtual const char *getType() const {
- return def;
- }
- void run() {
- func();
- out->run();
- }
- Neurone *clone() const {
- return new NeuroneFunction0 <Func, void> (def, func, "");
- }
- };
- //--------------------------------------------------------------------------
- //
- // template class NeuroneFunction1
- //
- //--------------------------------------------------------------------------
- template <class Func, class Ret, class A0>
- class NeuroneFunction1 : public Neurone {
- Func func;
- Str def;
- void onValueGet() {
- getOutput(0).setValue(TypeToVariable <Ret> (func(VariableToType <A0> (getInput(0).getValue()).value)).value);
- }
- public:
- NeuroneFunction1(const char *def_, Func func_, const char *ret_name, const char *a0_name) {
- def = def_;
- func = func_;
- Output *output = new Output(this);
- output->getVariable().setType <Ret> ();
- addOutput(ret_name, output);
- output->setOnGetValueAction(Common::Action::create(this, &NeuroneFunction1 <Func, Ret, A0> ::onValueGet));
- Input *input = new Input(Variable());
- input->getVariable().setType <A0> ();
- addInput(a0_name, input);
- }
- //
- virtual const char *getType() const {
- return def;
- }
- Neurone *clone() const {
- return new NeuroneFunction1 <Func, Ret, A0> (def, func, getOutputName(0), getInputName(0));
- }
- };
- template <class Func, class A0>
- class NeuroneFunction1 <Func, void, A0> : public Neurone {
- Anandamide::Action *in;
- Anandamide::Event *out;
- Func func;
- Str def;
- public:
- NeuroneFunction1(const char *def_, Func func_, const char *ret_name, const char *a0_name) {
- def = def_;
- func = func_;
- in = createAction(this, &NeuroneFunction1 <Func, void, A0> ::run);
- out = new Event();
- addAction("in", in);
- addEvent("out", out);
- Input *input = new Input(Variable());
- input->getVariable().setType <A0> ();
- addInput(a0_name, input);
- }
- //
- virtual const char *getType() const {
- return def;
- }
- void run() {
- func(VariableToType <A0> (getInput(0).getValue()).value);
- out->run();
- }
- Neurone *clone() const {
- return new NeuroneFunction1 <Func, void, A0> (def, func, "", getInputName(0));
- }
- };
- //--------------------------------------------------------------------------
- //
- // template class NeuroneFunction2
- //
- //--------------------------------------------------------------------------
- template <class Func, class Ret, class A0, class A1>
- class NeuroneFunction2 : public Neurone {
- Func func;
- Str def;
- void onValueGet() {
- getOutput(0).setValue(TypeToVariable <Ret> (
- func(
- VariableToType <A0> (getInput(0).getValue()).value,
- VariableToType <A1> (getInput(1).getValue()).value
- )
- ).value);
- }
- public:
- NeuroneFunction2(const char *def_, Func func_, const char *ret_name, const char *a0_name, const char *a1_name) {
- def = def_;
- func = func_;
- Output *output = new Output(this);
- output->getVariable().setType <Ret> ();
- addOutput(ret_name, output);
- output->setOnGetValueAction(Common::Action::create(this, &NeuroneFunction2 <Func, Ret, A0, A1> ::onValueGet));
- Input *input = new Input(Variable());
- input->getVariable().setType <A0> ();
- addInput(a0_name, input);
- input = new Input(Variable());
- input->getVariable().setType <A1> ();
- addInput(a1_name, input);
- }
- //
- virtual const char *getType() const {
- return def;
- }
- Neurone *clone() const {
- return new NeuroneFunction2 <Func, Ret, A0, A1> (def, func, getOutputName(0), getInputName(0), getInputName(1));
- }
- };
- template <class Func, class A0, class A1>
- class NeuroneFunction2 <Func, void, A0, A1> : public Neurone {
- Anandamide::Action *in;
- Anandamide::Event *out;
- Func func;
- Str def;
- public:
- NeuroneFunction2(const char *def_, Func func_, const char *ret_name, const char *a0_name, const char *a1_name) {
- def = def_;
- func = func_;
- in = createAction(this, &NeuroneFunction2 <Func, void, A0, A1> ::run);
- out = new Event();
- addAction("in", in);
- addEvent("out", out);
- Input *input = new Input(Variable());
- input->getVariable().setType <A0> ();
- addInput(a0_name, input);
- input = new Input(Variable());
- input->getVariable().setType <A1> ();
- addInput(a1_name, input);
- }
- //
- virtual const char *getType() const {
- return def;
- }
- void run() {
- func(
- VariableToType <A0> (getInput(0).getValue()).value,
- VariableToType <A1> (getInput(1).getValue()).value
- );
- out->run();
- }
- Neurone *clone() const {
- return new NeuroneFunction2 <Func, void, A0, A1> (def, func, "", getInputName(0), getInputName(1));
- }
- };
- //--------------------------------------------------------------------------
- //
- // template class NeuroneFunction3
- //
- //--------------------------------------------------------------------------
- template <class Func, class Ret, class A0, class A1, class A2>
- class NeuroneFunction3 : public Neurone {
- Func func;
- Str def;
- void onValueGet() {
- getOutput(0).setValue(TypeToVariable <Ret> (
- func(
- VariableToType <A0> (getInput(0).getValue()).value,
- VariableToType <A1> (getInput(1).getValue()).value,
- VariableToType <A2> (getInput(2).getValue()).value
- )
- ).value);
- }
- public:
- NeuroneFunction3(const char *def_, Func func_, const char *ret_name, const char *a0_name, const char *a1_name, const char *a2_name) {
- def = def_;
- func = func_;
- Output *output = new Output(this);
- output->getVariable().setType <Ret> ();
- addOutput(ret_name, output);
- output->setOnGetValueAction(Common::Action::create(this, &NeuroneFunction3 <Func, Ret, A0, A1, A2> ::onValueGet));
- Input *input = new Input(Variable());
- input->getVariable().setType <A0> ();
- addInput(a0_name, input);
- input = new Input(Variable());
- input->getVariable().setType <A1> ();
- addInput(a1_name, input);
- input = new Input(Variable());
- input->getVariable().setType <A2> ();
- addInput(a2_name, input);
- }
- //
- virtual const char *getType() const {
- return def;
- }
- Neurone *clone() const {
- return new NeuroneFunction3 <Func, Ret, A0, A1, A2> (def, func, getOutputName(0), getInputName(0), getInputName(1), getInputName(2));
- }
- };
- template <class Func, class A0, class A1, class A2>
- class NeuroneFunction3 <Func, void, A0, A1, A2> : public Neurone {
- Anandamide::Action *in;
- Anandamide::Event *out;
- Func func;
- Str def;
- public:
- NeuroneFunction3(const char *def_, Func func_, const char *ret_name, const char *a0_name, const char *a1_name, const char *a2_name) {
- def = def_;
- func = func_;
- in = createAction(this, &NeuroneFunction3 <Func, void, A0, A1, A2> ::run);
- out = new Event();
- addAction("in", in);
- addEvent("out", out);
- Input *input = new Input(Variable());
- input->getVariable().setType <A0> ();
- addInput(a0_name, input);
- input = new Input(Variable());
- input->getVariable().setType <A1> ();
- addInput(a1_name, input);
- input = new Input(Variable());
- input->getVariable().setType <A2> ();
- addInput(a2_name, input);
- }
- //
- virtual const char *getType() const {
- return def;
- }
- void run() {
- func(
- VariableToType <A0> (getInput(0).getValue()).value,
- VariableToType <A1> (getInput(1).getValue()).value,
- VariableToType <A2> (getInput(2).getValue()).value
- );
- out->run();
- }
- Neurone *clone() const {
- return new NeuroneFunction3 <Func, void, A0, A1, A2> (def, func, "", getInputName(0), getInputName(1), getInputName(2));
- }
- };
- //--------------------------------------------------------------------------
- //
- // template class NeuroneFunction4
- //
- //--------------------------------------------------------------------------
- template <class Func, class Ret, class A0, class A1, class A2, class A3>
- class NeuroneFunction4 : public Neurone {
- Func func;
- Str def;
- void onValueGet() {
- getOutput(0).setValue(TypeToVariable <Ret> (
- func(
- VariableToType <A0> (getInput(0).getValue()).value,
- VariableToType <A1> (getInput(1).getValue()).value,
- VariableToType <A2> (getInput(2).getValue()).value,
- VariableToType <A3> (getInput(3).getValue()).value
- )
- ).value);
- }
- public:
- NeuroneFunction4(const char *def_, Func func_, const char *ret_name, const char *a0_name, const char *a1_name, const char *a2_name, const char *a3_name) {
- def = def_;
- func = func_;
- Output *output = new Output(this);
- output->getVariable().setType <Ret> ();
- addOutput(ret_name, output);
- output->setOnGetValueAction(Common::Action::create(this, &NeuroneFunction4 <Func, Ret, A0, A1, A2, A3> ::onValueGet));
- Input *input = new Input(Variable());
- input->getVariable().setType <A0> ();
- addInput(a0_name, input);
- input = new Input(Variable());
- input->getVariable().setType <A1> ();
- addInput(a1_name, input);
- input = new Input(Variable());
- input->getVariable().setType <A2> ();
- addInput(a2_name, input);
- input = new Input(Variable());
- input->getVariable().setType <A3> ();
- addInput(a3_name, input);
- }
- //
- virtual const char *getType() const {
- return def;
- }
- Neurone *clone() const {
- return new NeuroneFunction4 <Func, Ret, A0, A1, A2, A3> (def, func, getOutputName(0), getInputName(0), getInputName(1), getInputName(2), getInputName(3));
- }
- };
- template <class Func, class A0, class A1, class A2, class A3>
- class NeuroneFunction4 <Func, void, A0, A1, A2, A3> : public Neurone {
- Anandamide::Action *in;
- Anandamide::Event *out;
- Func func;
- Str def;
- public:
- NeuroneFunction4(const char *def_, Func func_, const char *ret_name, const char *a0_name, const char *a1_name, const char *a2_name, const char *a3_name) {
- def = def_;
- func = func_;
- in = createAction(this, &NeuroneFunction4 <Func, void, A0, A1, A2, A3> ::run);
- out = new Event();
- addAction("in", in);
- addEvent("out", out);
- Input *input = new Input(Variable());
- input->getVariable().setType <A0> ();
- addInput(a0_name, input);
- input = new Input(Variable());
- input->getVariable().setType <A1> ();
- addInput(a1_name, input);
- input = new Input(Variable());
- input->getVariable().setType <A2> ();
- addInput(a2_name, input);
- input = new Input(Variable());
- input->getVariable().setType <A3> ();
- addInput(a3_name, input);
- }
- //
- virtual const char *getType() const {
- return def;
- }
- void run() {
- func(
- VariableToType <A0> (getInput(0).getValue()).value,
- VariableToType <A1> (getInput(1).getValue()).value,
- VariableToType <A2> (getInput(2).getValue()).value,
- VariableToType <A3> (getInput(3).getValue()).value
- );
- out->run();
- }
- Neurone *clone() const {
- return new NeuroneFunction4 <Func, void, A0, A1, A2, A3> (def, func, "", getInputName(0), getInputName(1), getInputName(2), getInputName(3));
- }
- };
- static template <class Ret>
- Neurone *makeNeuroneFunction0(const char *def, Ret (*func)(), const char *ret_name) {
- return new NeuroneFunction0 <Ret (*)(), Ret> (def, func, ret_name);
- }
- static template <class Ret, class A0>
- Neurone *makeNeuroneFunction1(const char *def, Ret (*func)(A0), const char *ret_name, const char *a0_name) {
- return new NeuroneFunction1 <Ret (*)(A0), Ret, A0> (def, func, ret_name, a0_name);
- }
- static template <class Ret, class A0, class A1>
- Neurone *makeNeuroneFunction2(const char *def, Ret (*func)(A0, A1), const char *ret_name, const char *a0_name, const char *a1_name) {
- return new NeuroneFunction2 <Ret (*)(A0, A1), Ret, A0, A1> (def, func, ret_name, a0_name, a1_name);
- }
- static template <class Ret, class A0, class A1, class A2>
- Neurone *makeNeuroneFunction3(const char *def, Ret (*func)(A0, A1, A2), const char *ret_name, const char *a0_name, const char *a1_name, const char *a2_name) {
- return new NeuroneFunction3 <Ret (*)(A0, A1, A2), Ret, A0, A1, A2> (def, func, ret_name, a0_name, a1_name, a2_name);
- }
- static template <class Ret, class A0, class A1, class A2, class A3>
- Neurone *makeNeuroneFunction4(const char *def, Ret (*func)(A0, A1, A2, A3), const char *ret_name, const char *a0_name, const char *a1_name, const char *a2_name, const char *a3_name) {
- return new NeuroneFunction4 <Ret (*)(A0, A1, A2, A3), Ret, A0, A1, A2, A3> (def, func, ret_name, a0_name, a1_name, a2_name, a3_name);
- }