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_TYPELESSCONSTRAINT_H 00032 #define MOCKPP_TYPELESSCONSTRAINT_H 00033 00034 #include <mockpp/util/AutoPointer.h> 00035 00036 #include <mockpp/mockpp.h> // always first 00037 00038 #include <mockpp/constraint/Constraint.h> 00039 00040 00041 MOCKPP_NS_START 00042 00043 00047 class MOCKPP_API_DECL0 TypelessConstraint : public SelfDescribing 00048 { 00049 public: 00050 00051 typedef AutoPointer<TypelessConstraint> AP; 00052 00055 virtual ~TypelessConstraint(); 00056 00061 virtual bool typelessEval() const = 0; 00062 }; 00063 00064 00068 template <typename T> 00069 class TypelessConstraintAdapter : public Constraint<T> 00070 { 00071 public: 00072 00076 TypelessConstraintAdapter(typename TypelessConstraint::AP tc) 00077 : constraint(tc) 00078 { 00079 } 00080 00083 virtual ~TypelessConstraintAdapter() 00084 { 00085 } 00086 00091 virtual String describeTo( String &buffer ) const 00092 { 00093 return constraint->describeTo(buffer); 00094 } 00095 00102 virtual bool eval(const T& o) const 00103 { 00104 MOCKPP_UNUSED(o); 00105 return constraint->typelessEval(); 00106 } 00107 00108 private: 00109 00110 const typename TypelessConstraint::AP constraint; 00111 }; 00112 00113 00114 MOCKPP_NS_END 00115 00116 00117 #endif // MOCKPP_TYPELESSCONSTRAINT_H