diff options
author | Jörg Frings-Fürst <jff@merkur> | 2014-05-18 16:08:14 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <jff@merkur> | 2014-05-18 16:08:14 +0200 |
commit | a15cf65c44d5c224169c32ef5495b68c758134b7 (patch) | |
tree | 3419f58fc8e1b315ba8171910ee044c5d467c162 /libcult/cult/rtti/type-info.cxx |
Imported Upstream version 3.3.0.2upstream/3.3.0.2
Diffstat (limited to 'libcult/cult/rtti/type-info.cxx')
-rw-r--r-- | libcult/cult/rtti/type-info.cxx | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/libcult/cult/rtti/type-info.cxx b/libcult/cult/rtti/type-info.cxx new file mode 100644 index 0000000..5bc4040 --- /dev/null +++ b/libcult/cult/rtti/type-info.cxx @@ -0,0 +1,42 @@ +// file : cult/rtti/type-info.cxx +// author : Boris Kolpackov <boris@kolpackov.net> +// copyright : Copyright (c) 2005-2010 Boris Kolpackov +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +#include <cult/rtti/type-info.hxx> + +#include <cult/mm/static-ptr.hxx> + +#include <cult/containers/map.hxx> + +namespace Cult +{ + namespace RTTI + { + Access const Access::private_ (Access::private__); + Access const Access::protected_ (Access::protected__); + Access const Access::public_ (Access::public__); + + typedef + Containers::Map<TypeId, TypeInfo> + TypeInfoMap; + + static MM::StaticPtr<TypeInfoMap> map_; + + TypeInfo const& + lookup (TypeId const& type_id) + { + TypeInfoMap::ConstIterator i (map_->find (type_id)); + + if (i == map_->end ()) throw NoInfo (); + + return i->second; + } + + Void + insert (TypeInfo const& type_info) + { + map_->insert (TypeInfoMap::Pair (type_info.type_id (), type_info)); + } + } +} |