00001
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef MOCKPP_CHAINABLEMOCKOBJECT_MACRO_H
00033 #define MOCKPP_CHAINABLEMOCKOBJECT_MACRO_H
00034
00035 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00036
00037 #include <mockpp/mockpp.h>
00038
00040
00041
00042 #define MOCKPP_CONSTRUCT_CHAINABLE_MEMBERS(name) \
00043 name ## CoreMock(MOCKPP_PCHAR(#name) MOCKPP_PCHAR("CoreMock"), this)
00044
00046
00047
00048 #define MOCKPP_CHAINER_DECL_START(classname, methname, ArgCount, ReturnType, InvocationType) \
00049 friend class ChainerFor ## methname; \
00050 public: \
00051 class ChainerFor ## methname : public MOCKPP_NS::ChainingMockBuilder<MOCKPP_NS::ArgumentsMatchBuilder ## ArgCount< ReturnType, InvocationType > >\
00052 { \
00053 \
00054 public: \
00055 \
00056 ChainerFor ## methname(classname *cls) \
00057 : MOCKPP_NS::ChainingMockBuilder<MOCKPP_NS::ArgumentsMatchBuilder ## ArgCount< ReturnType, InvocationType > >(&cls->methname ## CoreMock, cls, MOCKPP_PCHAR("ChainerFor") MOCKPP_PCHAR(# methname)) \
00058 { \
00059 } \
00060 \
00061 virtual ~ChainerFor ## methname() \
00062 { \
00063 }
00064
00065
00066 #define MOCKPP_CHAINER_DECL_END }
00067
00068
00069 #define MOCKPP_CHAINER_DECL0(classname, methname, ReturnType, InvocationType) \
00070 MOCKPP_CHAINER_DECL_START(classname, methname, 0, ReturnType, InvocationType) \
00071 MOCKPP_CHAINER_DECL_END
00072
00073 #define MOCKPP_CHAINER_DECL1(classname, methname, ReturnType, InvocationType) \
00074 MOCKPP_CHAINER_DECL_START(classname, methname, 1, ReturnType, InvocationType) \
00075 MOCKPP_CHAINER_DECL_END
00076
00077 #define MOCKPP_CHAINER_DECL2(classname, methname, ReturnType, InvocationType) \
00078 MOCKPP_CHAINER_DECL_START(classname, methname, 2, ReturnType, InvocationType) \
00079 MOCKPP_CHAINER_DECL_END
00080
00081 #define MOCKPP_CHAINER_DECL3(classname, methname, ReturnType, InvocationType) \
00082 MOCKPP_CHAINER_DECL_START(classname, methname, 3, ReturnType, InvocationType) \
00083 MOCKPP_CHAINER_DECL_END
00084
00085 #define MOCKPP_CHAINER_DECL4(classname, methname, ReturnType, InvocationType) \
00086 MOCKPP_CHAINER_DECL_START(classname, methname, 4, ReturnType, InvocationType) \
00087 MOCKPP_CHAINER_DECL_END
00088
00089 #define MOCKPP_CHAINER_DECL5(classname, methname, ReturnType, InvocationType) \
00090 MOCKPP_CHAINER_DECL_START(classname, methname, 5, ReturnType, InvocationType) \
00091 MOCKPP_CHAINER_DECL_END
00092
00094
00100 #define MOCKPP_VOID_CHAINABLE0_IMPL(classname, m_name, \
00101 a_name) \
00102 { \
00103 MOCKPP_STL::string func_name (#m_name); \
00104 MOCKPP_NS::Invocation0 inv(getVerifiableName() + MOCKPP_PCHAR(".") MOCKPP_PCHAR(#m_name)); \
00105 m_name ## CoreMock.invoke(inv); \
00106 } \
00107 MOCKPP_MEMBER_RESTRICTOR_PRIVATE: \
00108 typedef MOCKPP_NS::Invocation0 m_name ## InvocationType; \
00109 mutable MOCKPP_NS::CoreMock<void, m_name ## InvocationType > m_name ## CoreMock; \
00110 MOCKPP_CHAINER_DECL0(classname, m_name, void, m_name ## InvocationType)
00111
00112
00120 #define MOCKPP_VOID_CHAINABLE1_IMPL(classname, m_name, m_type1, \
00121 a_name, v_type1) \
00122 { \
00123 MOCKPP_STL::string func_name (#m_name); \
00124 MOCKPP_NS::Invocation1< v_type1 > inv(getVerifiableName() + MOCKPP_PCHAR(".") MOCKPP_PCHAR(#m_name), (v_type1&)param1); \
00125 m_name ## CoreMock.invoke(inv); \
00126 } \
00127 MOCKPP_MEMBER_RESTRICTOR_PRIVATE: \
00128 typedef MOCKPP_NS::Invocation1< v_type1 > m_name ## InvocationType; \
00129 mutable MOCKPP_NS::CoreMock<void, m_name ## InvocationType > m_name ## CoreMock; \
00130 MOCKPP_CHAINER_DECL1(classname, m_name, void, m_name ## InvocationType)
00131
00132
00140 #define MOCKPP_VOID_CHAINABLE2_IMPL(classname, m_name, m_type1, m_type2, \
00141 a_name, v_type1, v_type2) \
00142 { \
00143 MOCKPP_STL::string func_name (#m_name); \
00144 MOCKPP_NS::Invocation2< v_type1, v_type2 > inv(getVerifiableName() + MOCKPP_PCHAR(".") MOCKPP_PCHAR(#m_name), (v_type1&)param1, (v_type2&)param2); \
00145 m_name ## CoreMock.invoke(inv); \
00146 } \
00147 MOCKPP_MEMBER_RESTRICTOR_PRIVATE: \
00148 typedef MOCKPP_NS::Invocation2< v_type1, v_type2 > m_name ## InvocationType; \
00149 mutable MOCKPP_NS::CoreMock<void, m_name ## InvocationType > m_name ## CoreMock; \
00150 MOCKPP_CHAINER_DECL2(classname, m_name, void, m_name ## InvocationType)
00151
00152
00164 #define MOCKPP_VOID_CHAINABLE3_IMPL(classname, m_name, m_type1, m_type2, m_type3, \
00165 a_name, v_type1, v_type2, v_type3) \
00166 { \
00167 MOCKPP_STL::string func_name (#m_name); \
00168 MOCKPP_NS::Invocation3< v_type1, v_type2, v_type3 > inv(getVerifiableName() + MOCKPP_PCHAR(".") MOCKPP_PCHAR(#m_name), (v_type1&)param1, (v_type2&)param2, (v_type3&)param3); \
00169 m_name ## CoreMock.invoke(inv); \
00170 } \
00171 MOCKPP_MEMBER_RESTRICTOR_PRIVATE: \
00172 typedef MOCKPP_NS::Invocation3< v_type1, v_type2, v_type3 > m_name ## InvocationType; \
00173 mutable MOCKPP_NS::CoreMock<void, m_name ## InvocationType > m_name ## CoreMock; \
00174 MOCKPP_CHAINER_DECL3(classname, m_name, void, m_name ## InvocationType)
00175
00176
00190 #define MOCKPP_VOID_CHAINABLE4_IMPL(classname, m_name, m_type1, m_type2, m_type3, m_type4, \
00191 a_name, v_type1, v_type2, v_type3, v_type4) \
00192 { \
00193 MOCKPP_STL::string func_name (#m_name); \
00194 MOCKPP_NS::Invocation4< v_type1, v_type2, v_type3, v_type4 > inv(getVerifiableName() + MOCKPP_PCHAR(".") MOCKPP_PCHAR(#m_name), (v_type1&)param1, (v_type2&)param2, (v_type3&)param3, (v_type4&)param4); \
00195 m_name ## CoreMock.invoke(inv); \
00196 } \
00197 MOCKPP_MEMBER_RESTRICTOR_PRIVATE: \
00198 typedef MOCKPP_NS::Invocation4< v_type1, v_type2, v_type3, v_type4 > m_name ## InvocationType; \
00199 mutable MOCKPP_NS::CoreMock<void, m_name ## InvocationType > m_name ## CoreMock; \
00200 MOCKPP_CHAINER_DECL4(classname, m_name, void, m_name ## InvocationType)
00201
00202
00218 #define MOCKPP_VOID_CHAINABLE5_IMPL(classname, m_name, m_type1, m_type2, m_type3, m_type4, m_type5, \
00219 a_name, v_type1, v_type2, v_type3, v_type4, v_type5) \
00220 { \
00221 MOCKPP_STL::string func_name (#m_name); \
00222 MOCKPP_NS::Invocation5< v_type1, v_type2, v_type3, v_type4, v_type5 > inv(getVerifiableName() + MOCKPP_PCHAR(".") MOCKPP_PCHAR(#m_name), (v_type1&)param1, (v_type2&)param2, (v_type3&)param3, (v_type4&)param4, (v_type5&)param5); \
00223 m_name ## CoreMock.invoke(inv); \
00224 } \
00225 MOCKPP_MEMBER_RESTRICTOR_PRIVATE: \
00226 typedef MOCKPP_NS::Invocation5< v_type1, v_type2, v_type3, v_type4, v_type5 > m_name ## InvocationType; \
00227 mutable MOCKPP_NS::CoreMock<void, m_name ## InvocationType > m_name ## CoreMock; \
00228 MOCKPP_CHAINER_DECL5(classname, m_name, void, m_name ## InvocationType)
00229
00231
00239 #define MOCKPP_CHAINABLE0_IMPL(classname, m_ret_type, m_name, \
00240 v_ret_type, a_name) \
00241 { \
00242 MOCKPP_STL::string func_name (#m_name); \
00243 MOCKPP_NS::Invocation0 inv(getVerifiableName() + MOCKPP_PCHAR(".") MOCKPP_PCHAR(#m_name)); \
00244 return m_name ## CoreMock.invoke(inv); \
00245 } \
00246 MOCKPP_MEMBER_RESTRICTOR_PRIVATE: \
00247 typedef MOCKPP_NS::Invocation0 m_name ## InvocationType; \
00248 mutable MOCKPP_NS::CoreMock< m_ret_type, m_name ## InvocationType > m_name ## CoreMock; \
00249 MOCKPP_CHAINER_DECL0(classname, m_name, m_ret_type, m_name ## InvocationType)
00250
00251
00261 #define MOCKPP_CHAINABLE1_IMPL(classname, m_ret_type, m_name, m_type1, \
00262 v_ret_type, a_name, v_type1) \
00263 { \
00264 MOCKPP_STL::string func_name (#m_name); \
00265 MOCKPP_NS::Invocation1< v_type1 > inv(getVerifiableName() + MOCKPP_PCHAR(".") MOCKPP_PCHAR(#m_name), (v_type1&)param1); \
00266 return m_name ## CoreMock.invoke(inv); \
00267 } \
00268 MOCKPP_MEMBER_RESTRICTOR_PRIVATE: \
00269 typedef MOCKPP_NS::Invocation1< v_type1 > m_name ## InvocationType; \
00270 mutable MOCKPP_NS::CoreMock< m_ret_type, m_name ## InvocationType > m_name ## CoreMock; \
00271 MOCKPP_CHAINER_DECL1(classname, m_name, m_ret_type, m_name ## InvocationType)
00272
00273
00283 #define MOCKPP_CHAINABLE2_IMPL(classname, m_ret_type, m_name, m_type1, m_type2, \
00284 v_ret_type, a_name, v_type1, v_type2) \
00285 { \
00286 MOCKPP_STL::string func_name (#m_name); \
00287 MOCKPP_NS::Invocation2< v_type1, v_type2 > inv(getVerifiableName() + MOCKPP_PCHAR(".") MOCKPP_PCHAR(#m_name), (v_type1&)param1, (v_type2&)param2); \
00288 return m_name ## CoreMock.invoke(inv); \
00289 } \
00290 MOCKPP_MEMBER_RESTRICTOR_PRIVATE: \
00291 typedef MOCKPP_NS::Invocation2< v_type1, v_type2 > m_name ## InvocationType; \
00292 mutable MOCKPP_NS::CoreMock< m_ret_type, m_name ## InvocationType > m_name ## CoreMock; \
00293 MOCKPP_CHAINER_DECL2(classname, m_name, m_ret_type, m_name ## InvocationType)
00294
00295
00309 #define MOCKPP_CHAINABLE3_IMPL(classname, m_ret_type, m_name, m_type1, m_type2, m_type3, \
00310 v_ret_type, a_name, v_type1, v_type2, v_type3) \
00311 { \
00312 MOCKPP_STL::string func_name (#m_name); \
00313 MOCKPP_NS::Invocation3< v_type1, v_type2, v_type3 > inv(getVerifiableName() + MOCKPP_PCHAR(".") MOCKPP_PCHAR(#m_name), (v_type1&)param1, (v_type2&)param2, (v_type3&)param3); \
00314 return m_name ## CoreMock.invoke(inv); \
00315 } \
00316 MOCKPP_MEMBER_RESTRICTOR_PRIVATE: \
00317 typedef MOCKPP_NS::Invocation3< v_type1, v_type2, v_type3 > m_name ## InvocationType; \
00318 mutable MOCKPP_NS::CoreMock< m_ret_type, m_name ## InvocationType > m_name ## CoreMock; \
00319 MOCKPP_CHAINER_DECL3(classname, m_name, m_ret_type, m_name ## InvocationType)
00320
00321
00337 #define MOCKPP_CHAINABLE4_IMPL(classname, m_ret_type, m_name, m_type1, m_type2, m_type3, m_type4, \
00338 v_ret_type, a_name, v_type1, v_type2, v_type3, v_type4) \
00339 { \
00340 MOCKPP_STL::string func_name (#m_name); \
00341 MOCKPP_NS::Invocation4< v_type1, v_type2, v_type3, v_type4 > inv(getVerifiableName() + MOCKPP_PCHAR(".") MOCKPP_PCHAR(#m_name), (v_type1&)param1, (v_type2&)param2, (v_type3&)param3, (v_type4&)param4); \
00342 return m_name ## CoreMock.invoke(inv); \
00343 } \
00344 MOCKPP_MEMBER_RESTRICTOR_PRIVATE: \
00345 typedef MOCKPP_NS::Invocation4< v_type1, v_type2, v_type3, v_type4 > m_name ## InvocationType; \
00346 mutable MOCKPP_NS::CoreMock< m_ret_type, m_name ## InvocationType > m_name ## CoreMock; \
00347 MOCKPP_CHAINER_DECL4(classname, m_name, m_ret_type, m_name ## InvocationType)
00348
00349
00367 #define MOCKPP_CHAINABLE5_IMPL(classname, m_ret_type, m_name, m_type1, m_type2, m_type3, m_type4, m_type5, \
00368 v_ret_type, a_name, v_type1, v_type2, v_type3, v_type4, v_type5) \
00369 { \
00370 MOCKPP_STL::string func_name (#m_name); \
00371 MOCKPP_NS::Invocation5< v_type1, v_type2, v_type3, v_type4, v_type5 > inv(getVerifiableName() + MOCKPP_PCHAR(".") MOCKPP_PCHAR(#m_name), (v_type1&)param1, (v_type2&)param2, (v_type3&)param3, (v_type4&)param4, (v_type5&)param5); \
00372 return m_name ## CoreMock.invoke(inv); \
00373 } \
00374 MOCKPP_MEMBER_RESTRICTOR_PRIVATE: \
00375 typedef MOCKPP_NS::Invocation5< v_type1, v_type2, v_type3, v_type4, v_type5 > m_name ## InvocationType; \
00376 mutable MOCKPP_NS::CoreMock< m_ret_type, m_name ## InvocationType > m_name ## CoreMock; \
00377 MOCKPP_CHAINER_DECL5(classname, m_name, m_ret_type, m_name ## InvocationType)
00378
00379
00380 #endif // DOXYGEN_SHOULD_SKIP_THIS
00381
00382
00383 #endif // MOCKPP_CHAINABLEMOCKOBJECT_MACRO_H