[Mockpp-commits] mockpp/mockpp/constraint IsInstanceOf.h,1.16,1.17
Brought to you by:
ewald-arnold
From: Ewald A. <ewa...@us...> - 2005-03-13 19:14:06
|
Update of /cvsroot/mockpp/mockpp/mockpp/constraint In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25526/mockpp/constraint Modified Files: IsInstanceOf.h Log Message: fixed actually non-working IsInstanceOf Index: IsInstanceOf.h =================================================================== RCS file: /cvsroot/mockpp/mockpp/mockpp/constraint/IsInstanceOf.h,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- IsInstanceOf.h 13 Mar 2005 17:14:32 -0000 1.16 +++ IsInstanceOf.h 13 Mar 2005 19:13:25 -0000 1.17 @@ -43,24 +43,27 @@ /** Tests whether the value is derived from the given class. + * A base class is needed since dynamic_cast checks for an existing traversal + * from \c derived to \c base. * @ingroup grp_constraint * @see mockpp::isA */ -template <typename T> -class IsInstanceOf : public Constraint<T*> +template <typename BASE, + typename DERIVED> +class IsInstanceOf : public Constraint<BASE*> { - public: + typedef BASE* pBASE; - typedef T* pT; + public: /** Evaluates the constraint * @param obj the object against which the constraint is evaluated. * @return true: obj meets the constraint, * @return false if it does not. */ - virtual bool eval( const pT &obj ) const + virtual bool eval( const pBASE &obj ) const { - return dynamic_cast<const T*>(obj) != 0; + return dynamic_cast<const DERIVED*>(obj) != 0; } /** Appends the description of this object to the buffer. @@ -70,7 +73,7 @@ virtual String describeTo( String &buffer ) const { buffer += MOCKPP_PCHAR("derived from ") - + MOCKPP_GET_STRING(typeid(T).name()); + + MOCKPP_GET_STRING(typeid(DERIVED).name()); return buffer; } }; |