00001 00009 /************************************************************************** 00010 00011 begin : Sun Oct 24 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 00031 #ifndef MOCKPP_STUBHOLDER_H 00032 #define MOCKPP_STUBHOLDER_H 00033 00034 #include <mockpp/util/AutoPointer.h> 00035 00036 #include <mockpp/mockpp.h> // always first 00037 00038 #include <mockpp/stub/Stub.h> 00039 #include <mockpp/stub/TypelessStub.h> 00040 00041 00042 MOCKPP_NS_START 00043 00044 00049 template <typename R, // Returntype 00050 typename I> // Invocation 00051 class StubHolder 00052 { 00053 public: 00054 00058 StubHolder(const AutoPointer<TypelessStub<R> > &in_stub) 00059 : stub(new TypelessStubAdapter<R, I>(in_stub)) 00060 {} 00061 00065 StubHolder(TypelessStub<R> *in_stub) 00066 : stub(new TypelessStubAdapter<R, I>(in_stub)) 00067 {} 00068 00072 StubHolder(Stub<R, I> *in_stub) 00073 : stub(in_stub) 00074 {} 00075 00076 #ifndef _MSC_VER 00077 00081 StubHolder(const AutoPointer<Stub<R, I> > &in_stub) 00082 : stub(in_stub) 00083 {} 00084 00085 #endif 00086 00091 Stub<R, I>* release() const // we we actually lie a bit 00092 { 00093 return stub.release(); 00094 } 00095 00100 operator AutoPointer<Stub<R, I> > () const // we we actually lie a bit 00101 { 00102 return stub; 00103 } 00104 00105 private: 00106 00107 mutable typename Stub<R, I>::AP stub; // we we actually lie a bit 00108 }; 00109 00110 00111 MOCKPP_NS_END 00112 00113 00114 #endif // MOCKPP_STUBHOLDER_H