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