00001 #ifndef Primitive_h
00002 #define Primitive_h
00003
00004
00005 namespace Tree {
00006
00007 #define DBL_PREFIX "D_"
00008 #define INT_PREFIX "I_"
00009 #define BOOL_PREFIX "B_"
00010 #define CHR_PREFIX "C_"
00011 #define STR_PREFIX "S_"
00012
00013 class Tree;
00014 namespace Primitives {
00015
00016
00023 enum terminal_type
00024 { Double, Int, Bool, Char, String };
00025
00026 class Primitive;
00027 typedef boost::shared_ptr<Primitive> PrimitiveP;
00028
00036 class Primitive
00037 {
00038 public:
00039 Primitive();
00040 virtual ~Primitive();
00041
00047 virtual void execute(void* result, Tree& tree) = 0;
00048 virtual bool initialize(StateP state);
00049 virtual void setValue(void* value);
00050 virtual void getValue(void* value);
00051 virtual PrimitiveP copyWithNode(PrimitiveP);
00052 virtual PrimitiveP assignToNode(PrimitiveP);
00053 void getNextArgument(void* result, Tree& tree);
00054 void skipNextArgument(Tree& tree);
00055 int getNumberOfArguments();
00056 void setName(std::string name);
00057 std::string getName();
00058 std::string getComplementName();
00059
00060 StateP state_;
00061
00062 protected:
00063 std::string name_;
00064 int nArguments_;
00065 std::string complementName_;
00066 };
00067
00068 }
00069 typedef boost::shared_ptr<Primitives::Primitive> PrimitiveP;
00070 }
00071
00072 #endif