00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef OST_QUERY_AST_HH
00020 #define OST_QUERY_AST_HH
00021
00022 #include <ost/mol/module_config.hh>
00023 #include <boost/variant.hpp>
00024 #include <ost/geom/vec3.hh>
00025 #include <ost/mol/view_type_fw.hh>
00026 #include <ost/mol/property_id.hh>
00027
00028 namespace ost { namespace mol { namespace impl {
00029
00034 class DLLEXPORT_OST_MOL WithinParam {
00035 public:
00036 WithinParam(const geom::Vec3& center, float radius);
00037 WithinParam(int ref, float radius);
00038 WithinParam();
00039
00040 float GetRadiusSquare() const;
00041
00042 bool operator==(const WithinParam& p) const;
00043
00044 const geom::Vec3& GetCenter() const;
00045 int GetRef() const;
00046 bool HasValidRef() const;
00047 private:
00048 geom::Vec3 center_;
00049 float radius_;
00050 int lazily_bound_ref_;
00051 };
00052
00053 typedef boost::variant<int, float, String, WithinParam> ParamType;
00054
00055
00056 class DLLEXPORT_OST_MOL Node {
00057 public:
00058 Node(): parent_(NULL) { }
00059 virtual ~Node() { }
00060 virtual void Dump(int level=0) const = 0;
00061
00062 Node* GetParent();
00063
00064 void SetParent(Node* parent);
00065 private:
00066 Node* parent_;
00067 };
00068
00069 typedef enum {
00070 LOP_OR, LOP_AND
00071 } LogicOP;
00072
00073
00074
00075 class DLLEXPORT_OST_MOL LogicOPNode : public Node {
00076 public:
00077 LogicOPNode(LogicOP op);
00078
00079 ~LogicOPNode();
00080
00082 void SetRHS(Node* rhs);
00083
00085 void SetLHS(Node* lhs);
00086
00088 const Node* GetRHS() const;
00089
00091 const Node* GetLHS() const;
00092
00093
00095 LogicOP GetOP() const;
00096
00097 void SetOP(LogicOP op);
00098
00099 virtual void Dump(int level=0) const;
00100
00101 private:
00102 Node* lhs_;
00103 Node* rhs_;
00104 LogicOP op_;
00105 };
00106
00107 typedef enum {
00108 COP_EQ, COP_NEQ, COP_GE, COP_LE, COP_LT, COP_GT
00109 } CompOP;
00110
00111
00112 class DLLEXPORT_OST_MOL SelNode : public Node {
00113 public:
00114 SelNode(const Prop& sel, CompOP op, const ParamType& value)
00115 : sel_(sel), op_(op), param_(value)
00116 { }
00117
00118 SelNode(const SelNode& rhs)
00119 : sel_(rhs.sel_), op_(rhs.op_),param_(rhs.param_)
00120 { }
00121
00122 virtual void Dump(int level=0) const;
00123
00124 const Prop& GetAtomProps() const {
00125 return sel_;
00126 }
00127 CompOP GetCompOP() const {
00128 return op_;
00129 }
00130 const ParamType& GetParm() const {
00131 return param_;
00132 }
00133 private:
00134 Prop sel_;
00135 CompOP op_;
00136 ParamType param_;
00137
00138 };
00139
00140 }}}
00141
00142 #endif