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_OutBound_H
00031 #define MOCKPP_OutBound_H
00032
00033 #include <mockpp/mockpp.h>
00034
00035 #include <mockpp/constraint/Constraint.h>
00036 #include <mockpp/compat/Formatter.h>
00037 #include <mockpp/ReturnObjectList.h>
00038
00039
00040 MOCKPP_NS_START
00041
00042
00048 template <typename T>
00049 class OutBound : public Constraint<T>
00050 {
00051 public:
00052
00056 OutBound( const T &retArg )
00057 : returnObjects(MOCKPP_PCHAR("OutBound/returnObjects"), 0)
00058 {
00059 addOutboundObject(retArg);
00060 }
00061
00066 template <class I>
00067 OutBound( I items, I end )
00068 : returnObjects(MOCKPP_PCHAR("Outbound/returnObjects"), 0)
00069 {
00070 addOutboundObject(items, end);
00071 }
00072
00076 void addOutboundObject( const T &retArg )
00077 {
00078 returnObjects.addObjectToReturn(retArg);
00079 }
00080
00086 template <class I>
00087 OutBound& addOutboundObject(I items, I end)
00088 {
00089 for ( ; items != end; ++items)
00090 addOutboundObject(*items);
00091 return *this;
00092 }
00093
00096 virtual ~OutBound()
00097 {}
00098
00105 virtual bool eval( const T &arg ) const
00106 {
00107 if (returnObjects.hasMoreObjects())
00108 {
00109 T &back_ref = const_cast<T&>(arg);
00110 back_ref = returnObjects.nextReturnObject();
00111 return true;
00112 }
00113
00114 return false;
00115 }
00116
00122 virtual bool verify( const T & ) const
00123 {
00124 return returnObjects.hasMoreObjects() == 0;
00125 }
00126
00131 virtual String describeTo( String &buffer ) const
00132 {
00133 String fmt = MOCKPP_PCHAR("returns %1");
00134 fmt << returnObjects.toString();
00135 buffer += fmt;
00136 return buffer;
00137 }
00138
00139 private:
00140
00141 mutable ReturnObjectList<T> returnObjects;
00142 };
00143
00144
00145 MOCKPP_NS_END
00146
00147
00148 #endif // MOCKPP_OutBound_H