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 00031 #ifndef MOCKPP_TYPELESSMATCHER_H 00032 #define MOCKPP_TYPELESSMATCHER_H 00033 00034 00035 #include <mockpp/mockpp.h> // always first 00036 00037 #include <mockpp/chaining/Invocation.h> 00038 00039 #include <mockpp/Verifiable.h> 00040 #include <mockpp/SelfDescribing.h> 00041 00042 #include <mockpp/matcher/InvocationMatcher.h> 00043 00044 00045 MOCKPP_NS_START 00046 00047 00051 class MOCKPP_API_DECL0 TypelessMatcher : public Verifiable, 00052 public SelfDescribing 00053 { 00054 public: 00055 00056 typedef AutoPointer<TypelessMatcher> AP; 00057 00060 TypelessMatcher(); 00061 00064 virtual ~TypelessMatcher(); 00065 00069 virtual bool hasDescription() = 0; 00070 00074 virtual bool matches( ) = 0; 00075 00078 virtual void incInvoked( ) = 0; 00079 00083 virtual void reset(); 00084 }; 00085 00086 00090 template <typename I> 00091 class TypelessMatcherAdapter : public InvocationMatcher<I> 00092 { 00093 public: 00094 00098 TypelessMatcherAdapter(TypelessMatcher::AP tm) 00099 : matcher(tm) 00100 { 00101 } 00102 00107 virtual bool matches( const I &invocation ) 00108 { 00109 MOCKPP_UNUSED(invocation); 00110 return matcher->matches(); 00111 } 00112 00116 virtual void incInvoked( const I &invocation ) 00117 { 00118 MOCKPP_UNUSED(invocation); 00119 matcher->incInvoked(); 00120 } 00121 00125 virtual void verify() 00126 { 00127 matcher->verify(); 00128 } 00129 00134 virtual String describeTo( String &buffer ) const 00135 { 00136 return matcher->describeTo(buffer); 00137 } 00138 00142 virtual bool hasDescription() 00143 { 00144 return matcher->hasDescription(); 00145 } 00146 00147 private: 00148 00149 const TypelessMatcher::AP matcher; 00150 }; 00151 00152 00153 MOCKPP_NS_END 00154 00155 00156 #endif // MOCKPP_TYPELESSMATCHER_H 00157