blob: 7575b9f1b5a968fc6d3aba5f796da376770e395d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
// file : XSCRT/ExtendedTypeInfo.hpp
// author : Boris Kolpackov <boris@dre.vanderbilt.edu>
// cvs-id : $Id$
#ifndef XSCRT_EXTENDED_TYPE_INFO_HPP
#define XSCRT_EXTENDED_TYPE_INFO_HPP
#include <map>
#include <vector>
#include <typeinfo>
namespace XSCRT
{
//
//
//
class TypeId
{
public:
template<typename T>
TypeId (T const& t);
TypeId (std::type_info const& tid);
public:
bool
operator == (TypeId const& other) const;
bool
operator != (TypeId const& other) const;
bool
operator < (TypeId const& other) const;
/*
friend std::ostream&
operator << (std::ostream& os, TypeId const& t);
*/
public:
char const*
name () const
{
return tid_->name ();
}
private:
std::type_info const* tid_;
};
//
//
//
class ExtendedTypeInfo
{
public:
//
//
//
struct Access
{
enum Value
{
private_,
protected_,
public_
};
};
//
//
//
class BaseInfo
{
public:
BaseInfo (Access::Value access, bool virtual_base, TypeId const& tid);
public:
ExtendedTypeInfo const&
type_info () const;
Access::Value
access () const;
bool
virtual_base () const;
private:
TypeId tid_;
mutable ExtendedTypeInfo const* ti_;
bool virtual_base_;
Access::Value access_;
};
private:
typedef
std::vector<BaseInfo>
BaseInfoList;
public:
typedef
BaseInfoList::const_iterator
BaseIterator;
public:
ExtendedTypeInfo (TypeId const& tid);
TypeId
type_id () const;
BaseIterator
begin_base () const;
BaseIterator
end_base () const;
void
add_base (Access::Value access, bool virtual_base, TypeId const& tid);
private:
TypeId tid_;
BaseInfoList base_;
};
typedef
std::map<TypeId, ExtendedTypeInfo>
ExtendedTypeInfoMap;
ExtendedTypeInfoMap&
extended_type_info_map ();
class NotAvailable {};
template<typename T>
ExtendedTypeInfo const&
extended_type_info (T const& t)
{
return extended_type_info (typeid (t));
}
template<typename T>
ExtendedTypeInfo const&
extended_type_info ()
{
return extended_type_info (typeid (T));
}
//@@ Had to use function template specialization because VC6
// cannot handle simply overloaded functions.
//
template <>
inline
ExtendedTypeInfo const&
extended_type_info<TypeId> (TypeId const& tid)
{
ExtendedTypeInfoMap::const_iterator i (
extended_type_info_map ().find (tid));
if (i == extended_type_info_map ().end ()) throw NotAvailable ();
return i->second;
}
template <>
inline
ExtendedTypeInfo const&
extended_type_info<std::type_info> (std::type_info const& tid)
{
return extended_type_info (TypeId (tid));
}
}
#include <ace/XML_Utils/XSCRT/ExtendedTypeInfo.ipp>
#endif // XSCRT_EXTENDED_TYPE_INFO_HPP
|