From a15cf65c44d5c224169c32ef5495b68c758134b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 18 May 2014 16:08:14 +0200 Subject: Imported Upstream version 3.3.0.2 --- libcult/cult/rtti/type-info.hxx | 147 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 libcult/cult/rtti/type-info.hxx (limited to 'libcult/cult/rtti/type-info.hxx') diff --git a/libcult/cult/rtti/type-info.hxx b/libcult/cult/rtti/type-info.hxx new file mode 100644 index 0000000..dce4923 --- /dev/null +++ b/libcult/cult/rtti/type-info.hxx @@ -0,0 +1,147 @@ +// file : cult/rtti/type-info.hxx +// author : Boris Kolpackov +// copyright : Copyright (c) 2005-2010 Boris Kolpackov +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#ifndef CULT_RTTI_TYPE_INFO_HXX +#define CULT_RTTI_TYPE_INFO_HXX + +#include + +#include + +#include + +#include // std::type_info + +namespace Cult +{ + namespace RTTI + { + // + // + // + class Access + { + public: + static Access const private_, protected_, public_; + + friend Boolean + operator== (Access const& a, Access const& b) + { + return a.v_ == b.v_; + } + + friend Boolean + operator!= (Access const& a, Access const& b) + { + return a.v_ != b.v_; + } + + private: + enum Value { private__, protected__, public__ } v_; + + Access (Value v) + : v_ (v) + { + } + }; + + // + // + class TypeInfo; + + + // + // + class BaseInfo + { + public: + BaseInfo (Access access, Boolean virtual_, TypeId const& type_id); + + public: + TypeInfo const& + type_info () const; + + Access + access () const; + + Boolean + virtual_ () const; + + private: + Access access_; + Boolean virtual__; + TypeId type_id_; + mutable TypeInfo const* type_info_; + }; + + + // + // + class TypeInfo + { + typedef Containers::Vector BaseInfoList; + + public: + typedef + BaseInfoList::ConstIterator + BaseIterator; + + public: + TypeInfo (TypeId const& type_id); + + TypeId + type_id () const; + + BaseIterator + begin_base () const; + + BaseIterator + end_base () const; + + Void + add_base (Access access, Boolean virtual_, TypeId const& type_id); + + private: + TypeId type_id_; + BaseInfoList base_list_; + }; + + + // + // + class NoInfo {}; + + TypeInfo const& + lookup (TypeId const& type_id); + + inline + TypeInfo const& + lookup (std::type_info const& type_info) + { + return lookup (TypeId (type_info)); + } + + template + TypeInfo const& + lookup (X const& x) + { + return lookup (typeid (x)); + } + + template + TypeInfo const& + lookup () + { + return lookup (typeid (X)); + } + + Void + insert (TypeInfo const&); + } +} + +#include + +#endif // CULT_RTTI_TYPE_INFO_HXX -- cgit v1.2.3