Inferno
0.2
|
00001 #ifndef MATCH_HPP 00002 #define MATCH_HPP 00003 00004 #include <typeinfo> 00005 #include <string> 00006 #include "common/trace.hpp" 00007 00008 struct Matcher 00009 { 00010 virtual bool IsSubclass( const Matcher *source_architype ) const = 0; 00011 virtual bool IsLocalMatch( const Matcher *candidate ) const 00012 { 00013 // Default local matching criterion checks only the type of the candidate. If the 00014 // candidate's class is a (non-strict) subclass of this class, we have a match. 00015 return IsSubclass( candidate ); 00016 } 00017 virtual ~Matcher() {} 00018 template< class TARGET_TYPE > 00019 static inline bool IsSubclassStatic( const TARGET_TYPE *target_architype, const Matcher *source_architype ) 00020 { 00021 ASSERT( source_architype ); 00022 (void)target_architype; // don't care about value of architypes; just want the type 00023 return !!dynamic_cast<const TARGET_TYPE *>(source_architype); 00024 } 00025 }; 00026 00027 #define MATCHER_FUNCTION \ 00028 virtual bool IsSubclass( const Matcher *source_architype ) const \ 00029 { \ 00030 return IsSubclassStatic( this, source_architype ); \ 00031 } 00032 00033 #endif 00034