00001
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef MOCKPP_ResponseVector6_H
00032 #define MOCKPP_ResponseVector6_H
00033
00034 #include <mockpp/constraint/ConstraintHolder.h>
00035 #include <mockpp/constraint/IsEqual.h>
00036 #include <mockpp/visiting/VisitableMockObject_template.h>
00037
00038
00039 MOCKPP_NS_START
00040
00041
00045 template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
00046 class ResponseThrowableVector6 : public ResponseVectorBase
00047 {
00048 public:
00049
00055 ResponseThrowableVector6(const String &aName, VerifiableList *parent)
00056 : ResponseVectorBase(aName, parent)
00057 {}
00058
00061 virtual ~ResponseThrowableVector6()
00062 {
00063 reset();
00064 }
00065
00076 void add(Throwable *throwable, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, const P6 &p6, unsigned count)
00077 {
00078 const ConstraintHolder<P1> h1 = new IsEqual<P1>(p1);
00079 const ConstraintHolder<P2> h2 = new IsEqual<P2>(p2);
00080 const ConstraintHolder<P3> h3 = new IsEqual<P3>(p3);
00081 const ConstraintHolder<P4> h4 = new IsEqual<P4>(p4);
00082 const ConstraintHolder<P5> h5 = new IsEqual<P5>(p5);
00083 const ConstraintHolder<P6> h6 = new IsEqual<P6>(p6);
00084 add(throwable, h1, h2, h3, h4, h5, h6, count);
00085 }
00086
00097 void add(Throwable *throwable,
00098 const ConstraintHolder<P1> &p1,
00099 const ConstraintHolder<P2> &p2,
00100 const ConstraintHolder<P3> &p3,
00101 const ConstraintHolder<P4> &p4,
00102 const ConstraintHolder<P5> &p5,
00103 const ConstraintHolder<P6> &p6,
00104 unsigned count)
00105 {
00106 counter.push_back(count);
00107 tvec.push_back(throwable);
00108 typename MOCKPP_NS::Constraint<P1>::AP cons1 (p1);
00109 typename MOCKPP_NS::Constraint<P2>::AP cons2 (p2);
00110 typename MOCKPP_NS::Constraint<P3>::AP cons3 (p3);
00111 typename MOCKPP_NS::Constraint<P4>::AP cons4 (p4);
00112 typename MOCKPP_NS::Constraint<P5>::AP cons5 (p5);
00113 typename MOCKPP_NS::Constraint<P6>::AP cons6 (p6);
00114 t1vec.push_back(cons1.release());
00115 t2vec.push_back(cons2.release());
00116 t3vec.push_back(cons3.release());
00117 t4vec.push_back(cons4.release());
00118 t5vec.push_back(cons5.release());
00119 t6vec.push_back(cons6.release());
00120 }
00121
00124 void reset()
00125 {
00126 counter.clear();
00127 tvec.reset();
00128
00129 for (unsigned i1 = 0; i1 < t1vec.size(); ++i1)
00130 delete t1vec[i1];
00131 t1vec.clear();
00132
00133 for (unsigned i2 = 0; i2 < t2vec.size(); ++i2)
00134 delete t2vec[i2];
00135 t2vec.clear();
00136
00137 for (unsigned i3 = 0; i3 < t3vec.size(); ++i3)
00138 delete t3vec[i3];
00139 t3vec.clear();
00140
00141 for (unsigned i4 = 0; i4 < t4vec.size(); ++i4)
00142 delete t4vec[i4];
00143 t4vec.clear();
00144
00145 for (unsigned i5 = 0; i5 < t5vec.size(); ++i5)
00146 delete t5vec[i5];
00147 t5vec.clear();
00148
00149 for (unsigned i6 = 0; i6 < t6vec.size(); ++i6)
00150 delete t6vec[i6];
00151 t6vec.clear();
00152 }
00153
00164 bool find(Throwable * &throwable, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, const P6 &p6)
00165 {
00166 for (unsigned i = 0; i < t1vec.size(); ++i)
00167 if ( counter[i] > 0
00168 && t1vec[i]->eval(p1)
00169 && t2vec[i]->eval(p2)
00170 && t3vec[i]->eval(p3)
00171 && t4vec[i]->eval(p4)
00172 && t5vec[i]->eval(p5)
00173 && t6vec[i]->eval(p6)
00174 )
00175 {
00176 if (tvec.at(i) == 0)
00177 return false;
00178
00179 if (counter[i] != MOCKPP_UNLIMITED)
00180 --counter[i];
00181
00182 throwable = tvec.at(i);
00183 return true;
00184 }
00185 return false;
00186 }
00187
00188 protected:
00189
00190 MOCKPP_STL::vector<Constraint<P1>*> t1vec;
00191 MOCKPP_STL::vector<Constraint<P2>*> t2vec;
00192 MOCKPP_STL::vector<Constraint<P3>*> t3vec;
00193 MOCKPP_STL::vector<Constraint<P4>*> t4vec;
00194 MOCKPP_STL::vector<Constraint<P5>*> t5vec;
00195 MOCKPP_STL::vector<Constraint<P6>*> t6vec;
00196 };
00197
00198
00202 template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
00203 class ResponseVector6 : public ResponseThrowableVector6<P1, P2, P3, P4, P5, P6>
00204 {
00205 public:
00206
00211 ResponseVector6(const String &aName, VerifiableList *parent)
00212 : ResponseThrowableVector6<P1, P2, P3, P4, P5, P6>(aName, parent)
00213 {}
00214
00225 void add(Throwable *throwable, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, const P6 &p6, unsigned count)
00226 {
00227 MOCKPP_ASSERT_TRUE(throwable != 0);
00228 ResponseThrowableVector6<P1, P2, P3, P4, P5, P6>::add(throwable, p1, p2, p3, p4, p5, p6, count);
00229 R r;
00230 rvec.push_back(r);
00231 }
00232
00243 void add(Throwable *throwable,
00244 const ConstraintHolder<P1> &p1,
00245 const ConstraintHolder<P2> &p2,
00246 const ConstraintHolder<P3> &p3,
00247 const ConstraintHolder<P4> &p4,
00248 const ConstraintHolder<P5> &p5,
00249 const ConstraintHolder<P6> &p6,
00250 unsigned count)
00251 {
00252 MOCKPP_ASSERT_TRUE(throwable != 0);
00253 ResponseThrowableVector6<P1, P2, P3, P4, P5, P6>::add (throwable, p1, p2, p3, p4, p5, p6, count);
00254 R r;
00255 rvec.push_back(r);
00256 }
00257
00268 void add(const R &r, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, const P6 &p6, unsigned count)
00269 {
00270 ResponseThrowableVector6<P1, P2, P3, P4, P5, P6>::add((Throwable*)0, p1, p2, p3, p4, p5, p6, count);
00271 rvec.push_back(r);
00272 }
00273
00284 void add(const R &r,
00285 const ConstraintHolder<P1> &p1,
00286 const ConstraintHolder<P2> &p2,
00287 const ConstraintHolder<P3> &p3,
00288 const ConstraintHolder<P4> &p4,
00289 const ConstraintHolder<P5> &p5,
00290 const ConstraintHolder<P6> &p6,
00291 unsigned count)
00292 {
00293 ResponseThrowableVector6<P1, P2, P3, P4, P5, P6>::add((Throwable*)0, p1, p2, p3, p4, p5, p6, count);
00294 rvec.push_back(r);
00295 }
00296
00299 void reset()
00300 {
00301 ResponseThrowableVector6<P1, P2, P3, P4, P5, P6>::reset();
00302 rvec.clear();
00303 }
00304
00305 #if defined(__BORLANDC__) || (__GNUC__ < 3) // ==> BCB5.5.1 ?? F1004 Internal compiler error at 0x12548c1 with base 0x1200000
00306 bool find(Throwable * &throwable, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, const P6 &p6)
00307 {
00308 return ResponseThrowableVector6<P1, P2, P3, P4, P5, P6>::find(throwable, p1, p2, p3, p4, p5, p6);
00309 }
00310 #else
00311 using ResponseThrowableVector6<P1, P2, P3, P4, P5, P6>::find;
00312 #endif
00313
00324 bool find(R &r, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, const P6 &p6)
00325 {
00326 for (unsigned i = 0; i < this->t1vec.size(); ++i)
00327 if ( this->counter[i] > 0
00328 && this->t1vec[i]->eval(p1)
00329 && this->t2vec[i]->eval(p2)
00330 && this->t3vec[i]->eval(p3)
00331 && this->t4vec[i]->eval(p4)
00332 && this->t5vec[i]->eval(p5)
00333 && this->t6vec[i]->eval(p6)
00334 )
00335 {
00336 if (this->tvec.at(i) != 0)
00337 return false;
00338
00339 if (this->counter[i] != MOCKPP_UNLIMITED)
00340 --this->counter[i];
00341
00342 r = rvec[i];
00343 return true;
00344 }
00345 return false;
00346 }
00347
00348 private:
00349
00350 MOCKPP_STL::vector<R> rvec;
00351 };
00352
00353 MOCKPP_NS_END
00354
00355
00356 #endif // MOCKPP_ResponseVector6_H
00357