Thread: [Mockpp-commits] mockpp/mockpp ResponseVector1.h,NONE,1.1 ResponseVector2.h,NONE,1.1 ResponseVector3
Brought to you by:
ewald-arnold
Update of /cvsroot/mockpp/mockpp/mockpp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27372/mockpp Modified Files: Makefile.am VisitableMockObject_template.h Added Files: ResponseVector1.h ResponseVector2.h ResponseVector3.h ResponseVector4.h ResponseVector5.h Log Message: basic file set working --- NEW FILE: ResponseVector3.h --- /** @file @internal NOT INTENDED FOR PUBLIC INCLUSION @brief Generated with gen_responsevector_N.pl. $Id: ResponseVector3.h,v 1.1 2005/10/26 20:43:31 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Sat Feb 15 2003 copyright : (C) 2002-2005 by Ewald Arnold email : mockpp at ewald-arnold dot de This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. **/ #ifndef MOCKPP_ResponseVector3_H #define MOCKPP_ResponseVector3_H #include <mockpp/constraint/ConstraintHolder.h> #include <mockpp/constraint/IsEqual.h> namespace mockpp { /** Class returning a throwable depending on the parameters * passed to a method. */ template <typename P1, typename P2, typename P3> class ResponseThrowableVector3 : public ResponseVectorBase { public: /** * Construct a new empty vector * @param aName Label used to identify vector * @param parent parent verifiable */ ResponseThrowableVector3(const String &aName, VerifiableList *parent) : ResponseVectorBase(aName, parent) {} /** Destroys the vector */ virtual ~ResponseThrowableVector3() { reset(); } /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const P1 &p1, const P2 &p2, const P3 &p3, unsigned count) { const ConstraintHolder<P1> h1 = new IsEqual<P1>(p1); const ConstraintHolder<P2> h2 = new IsEqual<P2>(p2); const ConstraintHolder<P3> h3 = new IsEqual<P3>(p3); add(t, h1, h2, h3, count); } /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, unsigned count) { counter.push_back(count); tvec.push_back(t); typename mockpp::Constraint<P1>::AP cons1 (p1); typename mockpp::Constraint<P2>::AP cons2 (p2); typename mockpp::Constraint<P3>::AP cons3 (p3); t1vec.push_back(cons1.release()); t2vec.push_back(cons2.release()); t3vec.push_back(cons3.release()); } /** Removes all the objects from the list. */ virtual void reset() { clear(); } /** Removes all the objects from the list. */ void clear() { counter.clear(); tvec.clear(); for (unsigned i1 = 0; i1 < t1vec.size(); ++i1) delete t1vec[i1]; t1vec.clear(); for (unsigned i2 = 0; i2 < t2vec.size(); ++i2) delete t2vec[i2]; t2vec.clear(); for (unsigned i3 = 0; i3 < t3vec.size(); ++i3) delete t3vec[i3]; t3vec.clear(); } /** Finds a throwable for a set of parameters. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @return true: throwable found for parameters */ bool find(Throwable * &t, const P1 &p1, const P2 &p2, const P3 &p3) { for (unsigned i = 0; i < t1vec.size(); ++i) if ( counter[i] > 0 && t1vec[i]->eval(p1) && t2vec[i]->eval(p2) && t3vec[i]->eval(p3) ) { if (tvec.at(i) == 0) return false; if (counter[i] != MOCKPP_UNLIMITED) --counter[i]; t = tvec.at(i); return true; } return false; } protected: std::vector<Constraint<P1>*> t1vec; std::vector<Constraint<P2>*> t2vec; std::vector<Constraint<P3>*> t3vec; }; /** Class returning a throwable depending on the parameters * passed to a method. */ template <typename R, typename P1, typename P2, typename P3> class ResponseVector3 : public ResponseThrowableVector3<P1, P2, P3> { public: /** Construct a new empty vector * @param aName Label used to identify vector * @param parent parent verifiable */ ResponseVector3(const String &aName, VerifiableList *parent) : ResponseThrowableVector3<P1, P2, P3>(aName, parent) {} /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const P1 &p1, const P2 &p2, const P3 &p3, unsigned count) { MOCKPP_ASSERT_TRUE(t != 0); ResponseThrowableVector3<P1, P2, P3>::add(t, p1, p2, p3, count); R r; rvec.push_back(r); } /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, unsigned count) { MOCKPP_ASSERT_TRUE(t != 0); ResponseThrowableVector3<P1, P2, P3>::add (t, p1, p2, p3, count); R r; rvec.push_back(r); } /** Adds a return value. * @param r the return value * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param count the number of times the object may be used */ void add(const R &r, const P1 &p1, const P2 &p2, const P3 &p3, unsigned count) { ResponseThrowableVector3<P1, P2, P3>::add((Throwable*)0, p1, p2, p3, count); rvec.push_back(r); } /** Adds a return value. * @param r the return value * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param count the number of times the object may be used */ void add(const R &r, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, unsigned count) { ResponseThrowableVector3<P1, P2, P3>::add((Throwable*)0, p1, p2, p3, count); rvec.push_back(r); } /** Removes all the objects from the list. */ virtual void reset() { clear(); } /** Removes all the objects from the list. */ void clear() { ResponseThrowableVector3<P1, P2, P3>::clear(); rvec.clear(); } #if defined(__BORLANDC__) || (__GNUC__ < 3) // ==> BCB5.5.1 ?? F1004 Internal compiler error at 0x12548c1 with base 0x1200000 bool find(Throwable * &t, const P1 &p1, const P2 &p2, const P3 &p3) { return ResponseThrowableVector3<P1, P2, P3>::find(t, p1, p2, p3); } #else using ResponseThrowableVector3<P1, P2, P3>::find; #endif /** Finds a return value for a set of parameters. * @param r the value * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @return true: return value found for parameters */ bool find(R &r, const P1 &p1, const P2 &p2, const P3 &p3) { for (unsigned i = 0; i < this->t1vec.size(); ++i) if ( this->counter[i] > 0 && this->t1vec[i]->eval(p1) && this->t2vec[i]->eval(p2) && this->t3vec[i]->eval(p3) ) { if (this->tvec.at(i) != 0) return false; if (this->counter[i] != MOCKPP_UNLIMITED) --this->counter[i]; r = rvec[i]; return true; } return false; } private: std::vector<R> rvec; }; } // ns mockpp #endif // MOCKPP_ResponseVector3_H --- NEW FILE: ResponseVector4.h --- /** @file @internal NOT INTENDED FOR PUBLIC INCLUSION @brief Generated with gen_responsevector_N.pl. $Id: ResponseVector4.h,v 1.1 2005/10/26 20:43:31 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Sat Feb 15 2003 copyright : (C) 2002-2005 by Ewald Arnold email : mockpp at ewald-arnold dot de This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. **/ #ifndef MOCKPP_ResponseVector4_H #define MOCKPP_ResponseVector4_H #include <mockpp/constraint/ConstraintHolder.h> #include <mockpp/constraint/IsEqual.h> namespace mockpp { /** Class returning a throwable depending on the parameters * passed to a method. */ template <typename P1, typename P2, typename P3, typename P4> class ResponseThrowableVector4 : public ResponseVectorBase { public: /** * Construct a new empty vector * @param aName Label used to identify vector * @param parent parent verifiable */ ResponseThrowableVector4(const String &aName, VerifiableList *parent) : ResponseVectorBase(aName, parent) {} /** Destroys the vector */ virtual ~ResponseThrowableVector4() { reset(); } /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param p4 the parameter 4 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, unsigned count) { const ConstraintHolder<P1> h1 = new IsEqual<P1>(p1); const ConstraintHolder<P2> h2 = new IsEqual<P2>(p2); const ConstraintHolder<P3> h3 = new IsEqual<P3>(p3); const ConstraintHolder<P4> h4 = new IsEqual<P4>(p4); add(t, h1, h2, h3, h4, count); } /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param p4 the parameter 4 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, const ConstraintHolder<P4> &p4, unsigned count) { counter.push_back(count); tvec.push_back(t); typename mockpp::Constraint<P1>::AP cons1 (p1); typename mockpp::Constraint<P2>::AP cons2 (p2); typename mockpp::Constraint<P3>::AP cons3 (p3); typename mockpp::Constraint<P4>::AP cons4 (p4); t1vec.push_back(cons1.release()); t2vec.push_back(cons2.release()); t3vec.push_back(cons3.release()); t4vec.push_back(cons4.release()); } /** Removes all the objects from the list. */ virtual void reset() { clear(); } /** Removes all the objects from the list. */ void clear() { counter.clear(); tvec.clear(); for (unsigned i1 = 0; i1 < t1vec.size(); ++i1) delete t1vec[i1]; t1vec.clear(); for (unsigned i2 = 0; i2 < t2vec.size(); ++i2) delete t2vec[i2]; t2vec.clear(); for (unsigned i3 = 0; i3 < t3vec.size(); ++i3) delete t3vec[i3]; t3vec.clear(); for (unsigned i4 = 0; i4 < t4vec.size(); ++i4) delete t4vec[i4]; t4vec.clear(); } /** Finds a throwable for a set of parameters. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param p4 the parameter 4 upon which to return * @return true: throwable found for parameters */ bool find(Throwable * &t, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4) { for (unsigned i = 0; i < t1vec.size(); ++i) if ( counter[i] > 0 && t1vec[i]->eval(p1) && t2vec[i]->eval(p2) && t3vec[i]->eval(p3) && t4vec[i]->eval(p4) ) { if (tvec.at(i) == 0) return false; if (counter[i] != MOCKPP_UNLIMITED) --counter[i]; t = tvec.at(i); return true; } return false; } protected: std::vector<Constraint<P1>*> t1vec; std::vector<Constraint<P2>*> t2vec; std::vector<Constraint<P3>*> t3vec; std::vector<Constraint<P4>*> t4vec; }; /** Class returning a throwable depending on the parameters * passed to a method. */ template <typename R, typename P1, typename P2, typename P3, typename P4> class ResponseVector4 : public ResponseThrowableVector4<P1, P2, P3, P4> { public: /** Construct a new empty vector * @param aName Label used to identify vector * @param parent parent verifiable */ ResponseVector4(const String &aName, VerifiableList *parent) : ResponseThrowableVector4<P1, P2, P3, P4>(aName, parent) {} /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param p4 the parameter 4 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, unsigned count) { MOCKPP_ASSERT_TRUE(t != 0); ResponseThrowableVector4<P1, P2, P3, P4>::add(t, p1, p2, p3, p4, count); R r; rvec.push_back(r); } /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param p4 the parameter 4 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, const ConstraintHolder<P4> &p4, unsigned count) { MOCKPP_ASSERT_TRUE(t != 0); ResponseThrowableVector4<P1, P2, P3, P4>::add (t, p1, p2, p3, p4, count); R r; rvec.push_back(r); } /** Adds a return value. * @param r the return value * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param p4 the parameter 4 upon which to return * @param count the number of times the object may be used */ void add(const R &r, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, unsigned count) { ResponseThrowableVector4<P1, P2, P3, P4>::add((Throwable*)0, p1, p2, p3, p4, count); rvec.push_back(r); } /** Adds a return value. * @param r the return value * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param p4 the parameter 4 upon which to return * @param count the number of times the object may be used */ void add(const R &r, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, const ConstraintHolder<P4> &p4, unsigned count) { ResponseThrowableVector4<P1, P2, P3, P4>::add((Throwable*)0, p1, p2, p3, p4, count); rvec.push_back(r); } /** Removes all the objects from the list. */ virtual void reset() { clear(); } /** Removes all the objects from the list. */ void clear() { ResponseThrowableVector4<P1, P2, P3, P4>::clear(); rvec.clear(); } #if defined(__BORLANDC__) || (__GNUC__ < 3) // ==> BCB5.5.1 ?? F1004 Internal compiler error at 0x12548c1 with base 0x1200000 bool find(Throwable * &t, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4) { return ResponseThrowableVector4<P1, P2, P3, P4>::find(t, p1, p2, p3, p4); } #else using ResponseThrowableVector4<P1, P2, P3, P4>::find; #endif /** Finds a return value for a set of parameters. * @param r the value * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param p4 the parameter 4 upon which to return * @return true: return value found for parameters */ bool find(R &r, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4) { for (unsigned i = 0; i < this->t1vec.size(); ++i) if ( this->counter[i] > 0 && this->t1vec[i]->eval(p1) && this->t2vec[i]->eval(p2) && this->t3vec[i]->eval(p3) && this->t4vec[i]->eval(p4) ) { if (this->tvec.at(i) != 0) return false; if (this->counter[i] != MOCKPP_UNLIMITED) --this->counter[i]; r = rvec[i]; return true; } return false; } private: std::vector<R> rvec; }; } // ns mockpp #endif // MOCKPP_ResponseVector4_H --- NEW FILE: ResponseVector2.h --- /** @file @internal NOT INTENDED FOR PUBLIC INCLUSION @brief Generated with gen_responsevector_N.pl. $Id: ResponseVector2.h,v 1.1 2005/10/26 20:43:31 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Sat Feb 15 2003 copyright : (C) 2002-2005 by Ewald Arnold email : mockpp at ewald-arnold dot de This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. **/ #ifndef MOCKPP_ResponseVector2_H #define MOCKPP_ResponseVector2_H #include <mockpp/constraint/ConstraintHolder.h> #include <mockpp/constraint/IsEqual.h> namespace mockpp { /** Class returning a throwable depending on the parameters * passed to a method. */ template <typename P1, typename P2> class ResponseThrowableVector2 : public ResponseVectorBase { public: /** * Construct a new empty vector * @param aName Label used to identify vector * @param parent parent verifiable */ ResponseThrowableVector2(const String &aName, VerifiableList *parent) : ResponseVectorBase(aName, parent) {} /** Destroys the vector */ virtual ~ResponseThrowableVector2() { reset(); } /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const P1 &p1, const P2 &p2, unsigned count) { const ConstraintHolder<P1> h1 = new IsEqual<P1>(p1); const ConstraintHolder<P2> h2 = new IsEqual<P2>(p2); add(t, h1, h2, count); } /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, unsigned count) { counter.push_back(count); tvec.push_back(t); typename mockpp::Constraint<P1>::AP cons1 (p1); typename mockpp::Constraint<P2>::AP cons2 (p2); t1vec.push_back(cons1.release()); t2vec.push_back(cons2.release()); } /** Removes all the objects from the list. */ virtual void reset() { clear(); } /** Removes all the objects from the list. */ void clear() { counter.clear(); tvec.clear(); for (unsigned i1 = 0; i1 < t1vec.size(); ++i1) delete t1vec[i1]; t1vec.clear(); for (unsigned i2 = 0; i2 < t2vec.size(); ++i2) delete t2vec[i2]; t2vec.clear(); } /** Finds a throwable for a set of parameters. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @return true: throwable found for parameters */ bool find(Throwable * &t, const P1 &p1, const P2 &p2) { for (unsigned i = 0; i < t1vec.size(); ++i) if ( counter[i] > 0 && t1vec[i]->eval(p1) && t2vec[i]->eval(p2) ) { if (tvec.at(i) == 0) return false; if (counter[i] != MOCKPP_UNLIMITED) --counter[i]; t = tvec.at(i); return true; } return false; } protected: std::vector<Constraint<P1>*> t1vec; std::vector<Constraint<P2>*> t2vec; }; /** Class returning a throwable depending on the parameters * passed to a method. */ template <typename R, typename P1, typename P2> class ResponseVector2 : public ResponseThrowableVector2<P1, P2> { public: /** Construct a new empty vector * @param aName Label used to identify vector * @param parent parent verifiable */ ResponseVector2(const String &aName, VerifiableList *parent) : ResponseThrowableVector2<P1, P2>(aName, parent) {} /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const P1 &p1, const P2 &p2, unsigned count) { MOCKPP_ASSERT_TRUE(t != 0); ResponseThrowableVector2<P1, P2>::add(t, p1, p2, count); R r; rvec.push_back(r); } /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, unsigned count) { MOCKPP_ASSERT_TRUE(t != 0); ResponseThrowableVector2<P1, P2>::add (t, p1, p2, count); R r; rvec.push_back(r); } /** Adds a return value. * @param r the return value * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param count the number of times the object may be used */ void add(const R &r, const P1 &p1, const P2 &p2, unsigned count) { ResponseThrowableVector2<P1, P2>::add((Throwable*)0, p1, p2, count); rvec.push_back(r); } /** Adds a return value. * @param r the return value * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param count the number of times the object may be used */ void add(const R &r, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, unsigned count) { ResponseThrowableVector2<P1, P2>::add((Throwable*)0, p1, p2, count); rvec.push_back(r); } /** Removes all the objects from the list. */ virtual void reset() { clear(); } /** Removes all the objects from the list. */ void clear() { ResponseThrowableVector2<P1, P2>::clear(); rvec.clear(); } #if defined(__BORLANDC__) || (__GNUC__ < 3) // ==> BCB5.5.1 ?? F1004 Internal compiler error at 0x12548c1 with base 0x1200000 bool find(Throwable * &t, const P1 &p1, const P2 &p2) { return ResponseThrowableVector2<P1, P2>::find(t, p1, p2); } #else using ResponseThrowableVector2<P1, P2>::find; #endif /** Finds a return value for a set of parameters. * @param r the value * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @return true: return value found for parameters */ bool find(R &r, const P1 &p1, const P2 &p2) { for (unsigned i = 0; i < this->t1vec.size(); ++i) if ( this->counter[i] > 0 && this->t1vec[i]->eval(p1) && this->t2vec[i]->eval(p2) ) { if (this->tvec.at(i) != 0) return false; if (this->counter[i] != MOCKPP_UNLIMITED) --this->counter[i]; r = rvec[i]; return true; } return false; } private: std::vector<R> rvec; }; } // ns mockpp #endif // MOCKPP_ResponseVector2_H Index: VisitableMockObject_template.h =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/VisitableMockObject_template.h,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- VisitableMockObject_template.h 31 Jul 2005 14:22:57 -0000 1.26 +++ VisitableMockObject_template.h 26 Oct 2005 20:43:31 -0000 1.27 @@ -34,6 +34,7 @@ #include <mockpp/constraint/ConstraintHolder.h> #include <mockpp/constraint/IsEqual.h> + namespace mockpp { @@ -92,1288 +93,17 @@ std::vector<unsigned> counter; }; [...1273 lines suppressed...] - - private: - - std::vector<R> rvec; -}; - #endif // DOXYGEN_SHOULD_SKIP_THIS } // namespace mockpp +#include "ResponseVector1.h" +#include "ResponseVector2.h" +#include "ResponseVector3.h" +#include "ResponseVector4.h" +#include "ResponseVector5.h" + + #endif // MOCKPP_VISITABLEMOCKOBJECT_TEMPLATE_H + --- NEW FILE: ResponseVector1.h --- /** @file @internal NOT INTENDED FOR PUBLIC INCLUSION @brief Generated with gen_responsevector_N.pl. $Id: ResponseVector1.h,v 1.1 2005/10/26 20:43:31 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Sat Feb 15 2003 copyright : (C) 2002-2005 by Ewald Arnold email : mockpp at ewald-arnold dot de This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. **/ #ifndef MOCKPP_ResponseVector1_H #define MOCKPP_ResponseVector1_H #include <mockpp/constraint/ConstraintHolder.h> #include <mockpp/constraint/IsEqual.h> namespace mockpp { /** Class returning a throwable depending on the parameters * passed to a method. */ template <typename P1> class ResponseThrowableVector1 : public ResponseVectorBase { public: /** * Construct a new empty vector * @param aName Label used to identify vector * @param parent parent verifiable */ ResponseThrowableVector1(const String &aName, VerifiableList *parent) : ResponseVectorBase(aName, parent) {} /** Destroys the vector */ virtual ~ResponseThrowableVector1() { reset(); } /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const P1 &p1, unsigned count) { const ConstraintHolder<P1> h1 = new IsEqual<P1>(p1); add(t, h1, count); } /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const ConstraintHolder<P1> &p1, unsigned count) { counter.push_back(count); tvec.push_back(t); typename mockpp::Constraint<P1>::AP cons1 (p1); t1vec.push_back(cons1.release()); } /** Removes all the objects from the list. */ virtual void reset() { clear(); } /** Removes all the objects from the list. */ void clear() { counter.clear(); tvec.clear(); for (unsigned i1 = 0; i1 < t1vec.size(); ++i1) delete t1vec[i1]; t1vec.clear(); } /** Finds a throwable for a set of parameters. * @param t the throwable * @param p1 the parameter 1 upon which to return * @return true: throwable found for parameters */ bool find(Throwable * &t, const P1 &p1) { for (unsigned i = 0; i < t1vec.size(); ++i) if ( counter[i] > 0 && t1vec[i]->eval(p1) ) { if (tvec.at(i) == 0) return false; if (counter[i] != MOCKPP_UNLIMITED) --counter[i]; t = tvec.at(i); return true; } return false; } protected: std::vector<Constraint<P1>*> t1vec; }; /** Class returning a throwable depending on the parameters * passed to a method. */ template <typename R, typename P1> class ResponseVector1 : public ResponseThrowableVector1<P1> { public: /** Construct a new empty vector * @param aName Label used to identify vector * @param parent parent verifiable */ ResponseVector1(const String &aName, VerifiableList *parent) : ResponseThrowableVector1<P1>(aName, parent) {} /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const P1 &p1, unsigned count) { MOCKPP_ASSERT_TRUE(t != 0); ResponseThrowableVector1<P1>::add(t, p1, count); R r; rvec.push_back(r); } /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const ConstraintHolder<P1> &p1, unsigned count) { MOCKPP_ASSERT_TRUE(t != 0); ResponseThrowableVector1<P1>::add (t, p1, count); R r; rvec.push_back(r); } /** Adds a return value. * @param r the return value * @param p1 the parameter 1 upon which to return * @param count the number of times the object may be used */ void add(const R &r, const P1 &p1, unsigned count) { ResponseThrowableVector1<P1>::add((Throwable*)0, p1, count); rvec.push_back(r); } /** Adds a return value. * @param r the return value * @param p1 the parameter 1 upon which to return * @param count the number of times the object may be used */ void add(const R &r, const ConstraintHolder<P1> &p1, unsigned count) { ResponseThrowableVector1<P1>::add((Throwable*)0, p1, count); rvec.push_back(r); } /** Removes all the objects from the list. */ virtual void reset() { clear(); } /** Removes all the objects from the list. */ void clear() { ResponseThrowableVector1<P1>::clear(); rvec.clear(); } #if defined(__BORLANDC__) || (__GNUC__ < 3) // ==> BCB5.5.1 ?? F1004 Internal compiler error at 0x12548c1 with base 0x1200000 bool find(Throwable * &t, const P1 &p1) { return ResponseThrowableVector1<P1>::find(t, p1); } #else using ResponseThrowableVector1<P1>::find; #endif /** Finds a return value for a set of parameters. * @param r the value * @param p1 the parameter 1 upon which to return * @return true: return value found for parameters */ bool find(R &r, const P1 &p1) { for (unsigned i = 0; i < this->t1vec.size(); ++i) if ( this->counter[i] > 0 && this->t1vec[i]->eval(p1) ) { if (this->tvec.at(i) != 0) return false; if (this->counter[i] != MOCKPP_UNLIMITED) --this->counter[i]; r = rvec[i]; return true; } return false; } private: std::vector<R> rvec; }; } // ns mockpp #endif // MOCKPP_ResponseVector1_H Index: Makefile.am =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/Makefile.am,v retrieving revision 1.90 retrieving revision 1.91 diff -u -d -r1.90 -r1.91 --- Makefile.am 24 Oct 2005 19:08:44 -0000 1.90 +++ Makefile.am 26 Oct 2005 20:43:31 -0000 1.91 @@ -37,7 +37,12 @@ VisitableMockMethod2.h \ VisitableMockMethod3.h \ VisitableMockMethod4.h \ - VisitableMockMethod5.h + VisitableMockMethod5.h \ + ResponseVector1.h \ + ResponseVector2.h \ + ResponseVector3.h \ + ResponseVector4.h \ + ResponseVector5.h EXTRA_DIST = \ mockpp_config-bcb5.h \ @@ -47,7 +52,8 @@ visitable-template.raw \ chainable-template.h \ chainable-template.raw \ - gen_visitablemethod_N.pl + gen_visitablemethod_N.pl \ + gen_responsevector_N.pl CLEANFILES = *.~* *.~~* *~ mockpp_config.h *.old --- NEW FILE: ResponseVector5.h --- /** @file @internal NOT INTENDED FOR PUBLIC INCLUSION @brief Generated with gen_responsevector_N.pl. $Id: ResponseVector5.h,v 1.1 2005/10/26 20:43:31 ewald-arnold Exp $ ***************************************************************************/ /************************************************************************** begin : Sat Feb 15 2003 copyright : (C) 2002-2005 by Ewald Arnold email : mockpp at ewald-arnold dot de This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. **/ #ifndef MOCKPP_ResponseVector5_H #define MOCKPP_ResponseVector5_H #include <mockpp/constraint/ConstraintHolder.h> #include <mockpp/constraint/IsEqual.h> namespace mockpp { /** Class returning a throwable depending on the parameters * passed to a method. */ template <typename P1, typename P2, typename P3, typename P4, typename P5> class ResponseThrowableVector5 : public ResponseVectorBase { public: /** * Construct a new empty vector * @param aName Label used to identify vector * @param parent parent verifiable */ ResponseThrowableVector5(const String &aName, VerifiableList *parent) : ResponseVectorBase(aName, parent) {} /** Destroys the vector */ virtual ~ResponseThrowableVector5() { reset(); } /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param p4 the parameter 4 upon which to return * @param p5 the parameter 5 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, unsigned count) { const ConstraintHolder<P1> h1 = new IsEqual<P1>(p1); const ConstraintHolder<P2> h2 = new IsEqual<P2>(p2); const ConstraintHolder<P3> h3 = new IsEqual<P3>(p3); const ConstraintHolder<P4> h4 = new IsEqual<P4>(p4); const ConstraintHolder<P5> h5 = new IsEqual<P5>(p5); add(t, h1, h2, h3, h4, h5, count); } /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param p4 the parameter 4 upon which to return * @param p5 the parameter 5 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, const ConstraintHolder<P4> &p4, const ConstraintHolder<P5> &p5, unsigned count) { counter.push_back(count); tvec.push_back(t); typename mockpp::Constraint<P1>::AP cons1 (p1); typename mockpp::Constraint<P2>::AP cons2 (p2); typename mockpp::Constraint<P3>::AP cons3 (p3); typename mockpp::Constraint<P4>::AP cons4 (p4); typename mockpp::Constraint<P5>::AP cons5 (p5); t1vec.push_back(cons1.release()); t2vec.push_back(cons2.release()); t3vec.push_back(cons3.release()); t4vec.push_back(cons4.release()); t5vec.push_back(cons5.release()); } /** Removes all the objects from the list. */ virtual void reset() { clear(); } /** Removes all the objects from the list. */ void clear() { counter.clear(); tvec.clear(); for (unsigned i1 = 0; i1 < t1vec.size(); ++i1) delete t1vec[i1]; t1vec.clear(); for (unsigned i2 = 0; i2 < t2vec.size(); ++i2) delete t2vec[i2]; t2vec.clear(); for (unsigned i3 = 0; i3 < t3vec.size(); ++i3) delete t3vec[i3]; t3vec.clear(); for (unsigned i4 = 0; i4 < t4vec.size(); ++i4) delete t4vec[i4]; t4vec.clear(); for (unsigned i5 = 0; i5 < t5vec.size(); ++i5) delete t5vec[i5]; t5vec.clear(); } /** Finds a throwable for a set of parameters. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param p4 the parameter 4 upon which to return * @param p5 the parameter 5 upon which to return * @return true: throwable found for parameters */ bool find(Throwable * &t, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5) { for (unsigned i = 0; i < t1vec.size(); ++i) if ( counter[i] > 0 && t1vec[i]->eval(p1) && t2vec[i]->eval(p2) && t3vec[i]->eval(p3) && t4vec[i]->eval(p4) && t5vec[i]->eval(p5) ) { if (tvec.at(i) == 0) return false; if (counter[i] != MOCKPP_UNLIMITED) --counter[i]; t = tvec.at(i); return true; } return false; } protected: std::vector<Constraint<P1>*> t1vec; std::vector<Constraint<P2>*> t2vec; std::vector<Constraint<P3>*> t3vec; std::vector<Constraint<P4>*> t4vec; std::vector<Constraint<P5>*> t5vec; }; /** Class returning a throwable depending on the parameters * passed to a method. */ template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5> class ResponseVector5 : public ResponseThrowableVector5<P1, P2, P3, P4, P5> { public: /** Construct a new empty vector * @param aName Label used to identify vector * @param parent parent verifiable */ ResponseVector5(const String &aName, VerifiableList *parent) : ResponseThrowableVector5<P1, P2, P3, P4, P5>(aName, parent) {} /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param p4 the parameter 4 upon which to return * @param p5 the parameter 5 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, unsigned count) { MOCKPP_ASSERT_TRUE(t != 0); ResponseThrowableVector5<P1, P2, P3, P4, P5>::add(t, p1, p2, p3, p4, p5, count); R r; rvec.push_back(r); } /** Adds a throwable. * @param t the throwable * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param p4 the parameter 4 upon which to return * @param p5 the parameter 5 upon which to return * @param count the number of times the object may be used */ void add(Throwable *t, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, const ConstraintHolder<P4> &p4, const ConstraintHolder<P5> &p5, unsigned count) { MOCKPP_ASSERT_TRUE(t != 0); ResponseThrowableVector5<P1, P2, P3, P4, P5>::add (t, p1, p2, p3, p4, p5, count); R r; rvec.push_back(r); } /** Adds a return value. * @param r the return value * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param p4 the parameter 4 upon which to return * @param p5 the parameter 5 upon which to return * @param count the number of times the object may be used */ void add(const R &r, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, unsigned count) { ResponseThrowableVector5<P1, P2, P3, P4, P5>::add((Throwable*)0, p1, p2, p3, p4, p5, count); rvec.push_back(r); } /** Adds a return value. * @param r the return value * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param p4 the parameter 4 upon which to return * @param p5 the parameter 5 upon which to return * @param count the number of times the object may be used */ void add(const R &r, const ConstraintHolder<P1> &p1, const ConstraintHolder<P2> &p2, const ConstraintHolder<P3> &p3, const ConstraintHolder<P4> &p4, const ConstraintHolder<P5> &p5, unsigned count) { ResponseThrowableVector5<P1, P2, P3, P4, P5>::add((Throwable*)0, p1, p2, p3, p4, p5, count); rvec.push_back(r); } /** Removes all the objects from the list. */ virtual void reset() { clear(); } /** Removes all the objects from the list. */ void clear() { ResponseThrowableVector5<P1, P2, P3, P4, P5>::clear(); rvec.clear(); } #if defined(__BORLANDC__) || (__GNUC__ < 3) // ==> BCB5.5.1 ?? F1004 Internal compiler error at 0x12548c1 with base 0x1200000 bool find(Throwable * &t, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5) { return ResponseThrowableVector5<P1, P2, P3, P4, P5>::find(t, p1, p2, p3, p4, p5); } #else using ResponseThrowableVector5<P1, P2, P3, P4, P5>::find; #endif /** Finds a return value for a set of parameters. * @param r the value * @param p1 the parameter 1 upon which to return * @param p2 the parameter 2 upon which to return * @param p3 the parameter 3 upon which to return * @param p4 the parameter 4 upon which to return * @param p5 the parameter 5 upon which to return * @return true: return value found for parameters */ bool find(R &r, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5) { for (unsigned i = 0; i < this->t1vec.size(); ++i) if ( this->counter[i] > 0 && this->t1vec[i]->eval(p1) && this->t2vec[i]->eval(p2) && this->t3vec[i]->eval(p3) && this->t4vec[i]->eval(p4) && this->t5vec[i]->eval(p5) ) { if (this->tvec.at(i) != 0) return false; if (this->counter[i] != MOCKPP_UNLIMITED) --this->counter[i]; r = rvec[i]; return true; } return false; } private: std::vector<R> rvec; }; } // ns mockpp #endif // MOCKPP_ResponseVector5_H |