00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00030
00031 #ifndef ARMAGETRON_vCollection_h
00032 #define ARMAGETRON_vCollection_h
00033
00034 #include <set>
00035
00036 #include "values/vCore.h"
00037
00038 namespace vValue {
00039 namespace MiscWTF {
00040
00041 class FooPtrOps;
00042
00043 typedef std::set<BasePtr, FooPtrOps> myCol;
00044
00045 struct FooPtrOps
00046 {
00047 bool operator()( const BasePtr & a, const BasePtr & b )
00048 {
00049 return (*a < *b);
00050 }
00051
00052
00053
00054
00055
00056
00057
00058 };
00059
00060 }
00061 using namespace MiscWTF;
00062 namespace Expr {
00063 namespace Collection {
00064
00065 class BaseExt: public Base {
00066 public:
00067 BaseExt() :Base() {};
00068 BaseExt(Base const &other): Base(other) {};
00069 BaseExt(BaseExt const &other): Base(other) {};
00070 virtual ~BaseExt() { };
00071
00072 virtual Base *copy(void) const {return new BaseExt();};
00073
00076 virtual myCol GetCol(void) const ;
00077 operator myCol() const { return GetCol(); }
00078 };
00079
00080 class ColNode : public BaseExt {
00081 protected:
00082 myCol m_col;
00083
00084 public:
00085 template <typename InputIterator>
00086 ColNode(InputIterator begin, InputIterator end): BaseExt(), m_col(begin, end) { }
00087
00089
00090 ColNode(BaseExt const &other): BaseExt(other), m_col() { };
00091 ColNode(ColNode const &other): BaseExt(other), m_col(other.m_col) { };
00092 virtual ~ColNode() { };
00093
00094 Base *copy(void) const { return new ColNode(*this); };
00095 virtual Variant GetValue(void) const;
00096 virtual int GetInt(void) const;
00097 virtual float GetFloat(void) const;
00098 myCol GetCol(void) const;
00099
00100 bool operator==(Base const &other) const;
00101 bool operator!=(Base const &other) const;
00102 bool operator>=(Base const &other) const;
00103 bool operator<=(Base const &other) const;
00104 bool operator> (Base const &other) const;
00105 bool operator< (Base const &other) const;
00106 };
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125 class ColUnary : public BaseExt {
00126 protected:
00127 BasePtr m_child;
00128 public:
00129 ColUnary(BasePtr child) : BaseExt(), m_child(child) { };
00130
00131 ColUnary(const ColUnary &other): BaseExt(), m_child(other.m_child->copy()) { };
00132 virtual ~ColUnary() { };
00133
00134 Base *copy(void) const { return new ColUnary(*this); };
00135
00136 virtual Variant GetValue(void) const;
00137 virtual int GetInt(void) const;
00138 virtual float GetFloat(void) const;
00139 myCol GetCol(void) const;
00140
00141 bool operator==(Base const &other) const;
00142 bool operator!=(Base const &other) const;
00143 bool operator>=(Base const &other) const;
00144 bool operator<=(Base const &other) const;
00145 bool operator> (Base const &other) const;
00146 bool operator< (Base const &other) const;
00147 protected:
00148 virtual myCol _operation(void) const {
00149
00150 Base *base = m_child->copy();
00151 BaseExt const *baseExt = dynamic_cast<BaseExt*>(base);
00152 return baseExt->GetCol();
00153 };
00154 };
00155
00156
00157
00158
00159
00160
00161 class ColPickOne : public ColUnary {
00162 public:
00163 ColPickOne(BasePtr child = BasePtr( new Base() ) ) : ColUnary(child) { };
00164
00165 ColPickOne(const ColPickOne &other): ColUnary(other) { };
00166 virtual ~ColPickOne() { };
00167
00168 Base *copy(void) const { return new ColPickOne(*this); };
00169
00170 protected:
00171 virtual myCol _operation(void) const ;
00172 };
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191 class ColBinary : public BaseExt {
00192 protected:
00193 BasePtr r_child;
00194 BasePtr l_child;
00195
00196 public:
00197 ColBinary(BaseExt *r_value = new BaseExt,
00198 BaseExt *l_value = new BaseExt ) :
00199 r_child(r_value),
00200 l_child(l_value)
00201 { };
00202 ColBinary(BasePtr &r_value,
00203 BasePtr &l_value):
00204 r_child(r_value),
00205 l_child(l_value)
00206 { };
00207 ColBinary(const ColBinary &other) :
00208 BaseExt(other),
00209 r_child(other.r_child->copy()),
00210 l_child(other.l_child->copy())
00211 { };
00212 virtual ~ColBinary() { };
00213
00214 Base *copy(void) const { return new ColBinary(*this); };
00215
00216 virtual Variant GetValue(void) const;
00217 virtual int GetInt(void) const;
00218 virtual float GetFloat(void) const;
00219 myCol GetCol(void) const;
00220
00221 bool operator==(Base const &other) const;
00222 bool operator!=(Base const &other) const;
00223 bool operator>=(Base const &other) const;
00224 bool operator<=(Base const &other) const;
00225 bool operator> (Base const &other) const;
00226 bool operator< (Base const &other) const;
00227 protected:
00228 virtual myCol _operation(void) const;
00229 };
00230
00231
00232
00233 class ColUnion : public ColBinary {
00234 public:
00235 ColUnion(BaseExt *r_value = new BaseExt,
00236 BaseExt *l_value = new BaseExt ) :
00237 ColBinary(r_value, l_value)
00238 { };
00239 ColUnion(BasePtr &r_value,
00240 BasePtr &l_value):
00241 ColBinary(r_value, l_value) { };
00242 ColUnion(const ColBinary &other) :
00243 ColBinary(other) { };
00244 virtual ~ColUnion() { };
00245
00246 Base *copy(void) const { return new ColUnion(*this); };
00247
00248 protected:
00249 myCol _operation(void) const;
00250 };
00251
00252
00253 class ColIntersection : public ColBinary {
00254
00255 public:
00256 ColIntersection(BaseExt *r_value = new BaseExt,
00257 BaseExt *l_value = new BaseExt ) :
00258 ColBinary(r_value, l_value)
00259 { };
00260 ColIntersection(BasePtr &r_value,
00261 BasePtr &l_value):
00262 ColBinary(r_value, l_value) { };
00263 ColIntersection(const ColBinary &other) :
00264 ColBinary(other) { };
00265 virtual ~ColIntersection() { };
00266
00267 Base *copy(void) const { return new ColIntersection(*this); };
00268
00269 protected:
00270 myCol _operation(void) const;
00271 };
00272
00273
00274
00275 class ColDifference : public ColBinary {
00276 public:
00277 ColDifference(BaseExt *r_value = new BaseExt,
00278 BaseExt *l_value = new BaseExt ) :
00279 ColBinary(r_value, l_value)
00280 { };
00281 ColDifference(BasePtr &r_value,
00282 BasePtr &l_value):
00283 ColBinary(r_value, l_value) { };
00284 ColDifference(const ColBinary &other) :
00285 ColBinary(other) { };
00286 virtual ~ColDifference() { };
00287
00288 Base *copy(void) const { return new ColDifference(*this); };
00289
00290 protected:
00291 myCol _operation(void) const;
00292 };
00293
00294 }
00295 }
00296 }
00297
00298 #endif