00001 00009 /************************************************************************** 00010 00011 begin : Sun Aug 22 2004 00012 copyright : (C) 2002-2010 by Ewald Arnold 00013 email : mockpp at ewald-arnold dot de 00014 00015 This program is free software; you can redistribute it and/or modify 00016 it under the terms of the GNU Lesser General Public License as 00017 published by the Free Software Foundation; either version 2 of the License, 00018 or (at your option) any later version. 00019 00020 This program is distributed in the hope that it will be useful, 00021 but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 GNU General Public License for more details. 00024 00025 You should have received a copy of the GNU Lesser General Public License 00026 along with this program; if not, write to the Free Software 00027 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00028 00029 * 00030 * Original Java Sources: Copyright (c) 2000-2004, jMock.org 00031 * 00032 00033 **/ 00034 00035 #ifndef MOCKPP_STUBBUILDER_H 00036 #define MOCKPP_STUBBUILDER_H 00037 00038 #include <mockpp/mockpp.h> // always first 00039 00040 #include <mockpp/builder/IdentityBuilder.h> 00041 00042 #include <mockpp/stub/VoidStub.h> 00043 #include <mockpp/stub/StubHolder.h> 00044 00045 00046 MOCKPP_NS_START 00047 00048 00053 template <typename R, // Returntype 00054 typename I> // Invocation 00055 class StubBuilder : public IdentityBuilder 00056 { 00057 public: 00058 00059 #ifdef MOCKPP_PTI_WEAKNESS // Partial Template Instantiation Weakness 00060 00064 IdentityBuilder& isVoid() 00065 { 00066 setStub( new VoidStub()); 00067 return *this; 00068 } 00069 00070 #endif 00071 00077 IdentityBuilder& will( const StubHolder<R, I> &stubAction ) 00078 { 00079 setStub( stubAction ); 00080 return *this; 00081 } 00082 00086 virtual void setStub( const StubHolder<R, I> &stubAction ) = 0; 00087 }; 00088 00089 00090 #ifndef MOCKPP_PTI_WEAKNESS // Partial Template Instantiation Weakness 00091 00092 00097 template <typename I> // Invocation 00098 class StubBuilder<void, I> : public IdentityBuilder 00099 { 00100 public: 00101 00105 IdentityBuilder& isVoid() 00106 { 00107 setStub( new VoidStub()); 00108 return *this; 00109 } 00110 00116 IdentityBuilder& will( const StubHolder<void, I> &stubAction ) 00117 { 00118 setStub( stubAction ); 00119 return *this; 00120 } 00121 00125 virtual void setStub( const StubHolder<void, I> &stubAction ) = 0; 00126 }; 00127 00128 00129 #endif 00130 00131 00132 MOCKPP_NS_END 00133 00134 00135 #endif // MOCKPP_STUBBUILDER_H 00136