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_MATCHERHOLDER_H 00032 #define MOCKPP_MATCHERHOLDER_H 00033 00034 #include <mockpp/util/AutoPointer.h> 00035 00036 #include <mockpp/mockpp.h> // always first 00037 00038 #include <mockpp/matcher/InvocationMatcher.h> 00039 #include <mockpp/matcher/TypelessMatcher.h> 00040 00041 00042 MOCKPP_NS_START 00043 00044 00049 template <typename I> // Invocation 00050 class MatcherHolder 00051 { 00052 public: 00053 00057 MatcherHolder(InvocationMatcher<I> *in_matcher) 00058 : matcher(in_matcher) 00059 { 00060 } 00061 00065 MatcherHolder(const typename TypelessMatcher::AP &in_matcher) 00066 : matcher(new TypelessMatcherAdapter<I>(in_matcher)) 00067 { 00068 } 00069 00073 MatcherHolder(TypelessMatcher*in_matcher) 00074 : matcher(new TypelessMatcherAdapter<I>(in_matcher)) 00075 { 00076 } 00077 00081 MatcherHolder(const typename InvocationMatcher<I>::AP &in_matcher) 00082 : matcher(in_matcher) 00083 { 00084 } 00085 00090 #if defined(__BORLANDC__) && (__BORLANDC__ >= 560) 00091 operator typename AutoPointer<InvocationMatcher<I> > () const // we actually lie a bit 00092 #else 00093 operator typename InvocationMatcher<I>::AP () const 00094 #endif 00095 { 00096 return matcher; 00097 } 00098 00099 private: 00100 00101 mutable typename InvocationMatcher<I>::AP matcher; // we actually lie a bit 00102 }; 00103 00104 00105 MOCKPP_NS_END 00106 00107 00108 #endif // MOCKPP_MATCHERHOLDER_H