00001
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef MOCKPP_TypelessStubSequence_H
00031 #define MOCKPP_TypelessStubSequence_H
00032
00033 #include <mockpp/mockpp.h>
00034
00035 #include MOCKPP_VECTOR_H
00036
00037 #include <mockpp/stub/TypelessStub.h>
00038 #include <mockpp/compat/Asserter.h>
00039
00040
00041 MOCKPP_NS_START
00042
00043
00048 template <typename R>
00049 class TypelessStubSequence : public TypelessStub<R>
00050 {
00051 public:
00052
00057 template<typename P>
00058 TypelessStubSequence(P start, P end)
00059 : stubs(start, end)
00060 {}
00061
00064 virtual ~TypelessStubSequence()
00065 {
00066 while (!stubs.empty() )
00067 {
00068 delete stubs[0];
00069 stubs.erase(stubs.begin());
00070 }
00071 }
00072
00076 virtual R typelessInvoke()
00077 {
00078 if (!stubs.empty())
00079 {
00080 MOCKPP_STD_NS::auto_ptr< TypelessStub<R> > curr (stubs[0]);
00081 stubs.erase(stubs.begin());
00082 return curr->typelessInvoke();
00083 }
00084 assertionFailed(__LINE__, __FILE__, MOCKPP_PCHAR("no more stubs available"));
00085 return R();
00086 }
00087
00092 virtual String describeTo( String &buffer ) const
00093 {
00094 for (unsigned i = 0; i < stubs.size(); i++)
00095 {
00096 if (i > 0)
00097 buffer += MOCKPP_PCHAR(", and then ");
00098
00099 buffer = stubs[i]->describeTo(buffer);
00100 }
00101
00102 return buffer;
00103 }
00104
00105 private:
00106
00107
00108 TypelessStubSequence(const TypelessStubSequence &);
00109 TypelessStubSequence &operator =(const TypelessStubSequence &);
00110
00111 MOCKPP_STL::vector<TypelessStub<R>* > stubs;
00112 };
00113
00114
00115 MOCKPP_NS_END
00116
00117
00118 #endif // MOCKPP_TypelessStubSequence_H
00119