ECF 1.5
Pos.h
1#ifndef Pos_h
2#define Pos_h
3#include "Primitive.h"
4
5namespace Tree {
6namespace Primitives {
7
14template <class T>
15class PosT : public Primitive
16{
17public:
18 PosT();
19 void execute(void* result, Tree& tree);
20 ~PosT();
21};
22typedef PosT<double> Pos;
23
24
25template <class T>
27{
28 nArguments_ = 1;
29 name_ = "pos";
30 complementName_ = "neg";
31}
32
33
34template <class T>
35PosT<T>::~PosT()
36{ }
37
38
39template <class T>
40void PosT<T>::execute(void* result, Tree& tree)
41{
42 T arg;
43 T& pos = *(T*)result;
44 getNextArgument(&arg, tree);
45 pos = arg > 0 ? arg : 0;
46}
47
48}
49}
50
51#endif
Pos function primitive (Tree genotype)
Definition: Pos.h:16
void execute(void *result, Tree &tree)
Execute the primitive.
Definition: Pos.h:40
Base primitive class (Tree genotype).
Definition: Primitive.h:37
Tree class - implements genotype as a tree.
Definition: Tree_c.h:29