Debian Codegraph @

cutl/compiler/type-info.hxx

raw
1 // file : cutl/compiler/type-info.hxx
2 // copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC
3 // license : MIT; see accompanying LICENSE file
4
5 #ifndef CUTL_COMPILER_TYPE_INFO_HXX
6 #define CUTL_COMPILER_TYPE_INFO_HXX
7
8 #include <map>
9 #include <vector>
10 #include <typeinfo> // std::type_info
11
12 #include <cutl/exception.hxx>
13 #include <cutl/static-ptr.hxx>
14 #include <cutl/compiler/type-id.hxx>
15
16 #include <cutl/details/export.hxx>
17
18 namespace cutl
19 {
20 namespace compiler
21 {
22 //
23 //
24 class type_info;
25 typedef type_info type_info_t;
26
27
28 //
29 //
30 class LIBCUTL_EXPORT base_info
31 {
32 public:
33 base_info (type_id const&);
34
35 public:
36 type_info_t const&
37 type_info () const;
38
39 private:
40 type_id type_id_;
41 mutable type_info_t const* type_info_;
42 };
43
44 typedef base_info base_info_t;
45
46
47 //
48 //
49 class LIBCUTL_EXPORT type_info
50 {
51 typedef std::vector<base_info> bases;
52
53 public:
54 typedef
55 bases::const_iterator
56 base_iterator;
57
58 public:
59 type_info (type_id_t const&);
60
61 type_id_t
62 type_id () const;
63
64 base_iterator
65 begin_base () const;
66
67 base_iterator
68 end_base () const;
69
70 void
71 add_base (type_id_t const&);
72
73 private:
74 type_id_t type_id_;
75 bases bases_;
76 };
77
78
79 //
80 //
81 class LIBCUTL_EXPORT no_type_info: exception {};
82
83 LIBCUTL_EXPORT type_info const&
84 lookup (type_id const&);
85
86 LIBCUTL_EXPORT type_info const&
87 lookup (std::type_info const&);
88
89 template <typename X>
90 type_info const&
91 lookup (X const volatile&);
92
93 template<typename X>
94 type_info const&
95 lookup ();
96
97 LIBCUTL_EXPORT void
98 insert (type_info const&);
99
100 namespace bits
101 {
102 struct default_type_info_id {};
103 typedef std::map<type_id, type_info> type_info_map;
104 static static_ptr<type_info_map, default_type_info_id> type_info_map_;
105 }
106 }
107 }
108
109 #include <cutl/compiler/type-info.ixx>
110
111 #endif // CUTL_COMPILER_TYPE_INFO_HXX