00001 #ifndef PrimitiveSet_h
00002 #define PrimitiveSet_h
00003 #include <vector>
00004 #include "Primitive.h"
00005
00006
00007 namespace Tree
00008 {
00009
00017 class PrimitiveSet
00018 {
00019 friend class Tree;
00020 public:
00021 PrimitiveSet();
00022 virtual ~PrimitiveSet();
00023
00024 bool initialize(StateP state);
00025
00026
00027 bool addFunction(std::string name);
00028 void addTerminal(PrimitiveP terminalPrimitive);
00029
00030 PrimitiveP getRandomTerminal();
00031 PrimitiveP getRandomFunction();
00032 PrimitiveP getRandomPrimitive();
00033
00034 PrimitiveP getTerminalByName(std::string name);
00035 PrimitiveP getFunctionByName(std::string name);
00036 PrimitiveP getPrimitiveByName(std::string name);
00037
00038 uint getFunctionSetSize();
00039 uint getTerminalSetSize();
00040 uint getPrimitivesSize();
00041
00042 protected:
00043 StateP state_;
00044
00045 std::map <std::string, PrimitiveP> mAllPrimitives_;
00046 std::map <std::string, Primitives::terminal_type> mTypeNames_;
00047
00048 std::vector<PrimitiveP> terminalSet_;
00049 std::map <std::string, PrimitiveP> mTerminalSet_;
00050 std::vector<PrimitiveP> functionSet_;
00051 std::map <std::string, PrimitiveP> mFunctionSet_;
00052 std::vector<PrimitiveP> primitives_;
00053 std::map <std::string, PrimitiveP> mPrimitiveSet_;
00054 };
00055 typedef boost::shared_ptr<PrimitiveSet> PrimitiveSetP;
00056
00057 typedef std::map <std::string, PrimitiveP>::iterator prim_iter;
00058 typedef std::map <std::string, Primitives::terminal_type>::iterator type_iter;
00059
00060 }
00061 #endif