00001 #ifndef TYPELIB_VISITOR_HH 00002 #define TYPELIB_VISITOR_HH 00003 00004 #include "typemodel.hh" 00005 00006 namespace Typelib 00007 { 00008 class UnsupportedType : public TypeException 00009 { 00010 public: 00011 Type const& type; 00012 std::string const reason; 00013 UnsupportedType(Type const& type_) 00014 : TypeException("type " + type_.getName() + " not supported"), type(type_) {} 00015 UnsupportedType(Type const& type_, std::string const& reason_) 00016 : TypeException("type " + type_.getName() + " not supported: " + reason_), type(type_), reason(reason_) {} 00017 ~UnsupportedType() throw() { } 00018 }; 00019 00027 class TypeVisitor 00028 { 00029 protected: 00030 bool dispatch(Type const& type); 00031 00032 virtual bool visit_ (NullType const& type); 00033 virtual bool visit_ (OpaqueType const& type); 00034 virtual bool visit_ (Numeric const& type); 00035 virtual bool visit_ (Enum const& type); 00036 00037 virtual bool visit_ (Pointer const& type); 00038 virtual bool visit_ (Array const& type); 00039 virtual bool visit_ (Container const& type); 00040 00041 virtual bool visit_ (Compound const& type); 00042 virtual bool visit_ (Compound const& type, Field const& field); 00043 00044 public: 00045 virtual ~TypeVisitor() {} 00046 void apply(Type const& type); 00047 }; 00048 } 00049 00050 #endif 00051