sl@0
|
1 |
// (C) Copyright Gennadiy Rozental 2005.
|
sl@0
|
2 |
// Distributed under the Boost Software License, Version 1.0.
|
sl@0
|
3 |
// (See accompanying file LICENSE_1_0.txt or copy at
|
sl@0
|
4 |
// http://www.boost.org/LICENSE_1_0.txt)
|
sl@0
|
5 |
|
sl@0
|
6 |
// See http://www.boost.org/libs/test for the library home page.
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// File : $RCSfile: rtti.hpp,v $
|
sl@0
|
9 |
//
|
sl@0
|
10 |
// Version : $Revision: 1.2 $
|
sl@0
|
11 |
//
|
sl@0
|
12 |
// Description : simple facilities for accessing type information at runtime
|
sl@0
|
13 |
// ***************************************************************************
|
sl@0
|
14 |
|
sl@0
|
15 |
#ifndef BOOST_TEST_RTTI_HPP_062604GER
|
sl@0
|
16 |
#define BOOST_TEST_RTTI_HPP_062604GER
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <cstddef>
|
sl@0
|
19 |
|
sl@0
|
20 |
namespace boost {
|
sl@0
|
21 |
|
sl@0
|
22 |
namespace rtti {
|
sl@0
|
23 |
|
sl@0
|
24 |
// ************************************************************************** //
|
sl@0
|
25 |
// ************** rtti::type_id ************** //
|
sl@0
|
26 |
// ************************************************************************** //
|
sl@0
|
27 |
|
sl@0
|
28 |
typedef std::ptrdiff_t id_t;
|
sl@0
|
29 |
|
sl@0
|
30 |
namespace rtti_detail {
|
sl@0
|
31 |
|
sl@0
|
32 |
template<typename T>
|
sl@0
|
33 |
struct rttid_holder {
|
sl@0
|
34 |
static id_t id() { return reinterpret_cast<id_t>( &inst() ); }
|
sl@0
|
35 |
|
sl@0
|
36 |
private:
|
sl@0
|
37 |
struct rttid {};
|
sl@0
|
38 |
|
sl@0
|
39 |
static rttid const& inst() { static rttid s_inst; return s_inst; }
|
sl@0
|
40 |
};
|
sl@0
|
41 |
|
sl@0
|
42 |
} // namespace rtti_detail
|
sl@0
|
43 |
|
sl@0
|
44 |
//____________________________________________________________________________//
|
sl@0
|
45 |
|
sl@0
|
46 |
template<typename T>
|
sl@0
|
47 |
inline id_t
|
sl@0
|
48 |
type_id()
|
sl@0
|
49 |
{
|
sl@0
|
50 |
return rtti_detail::rttid_holder<T>::id();
|
sl@0
|
51 |
}
|
sl@0
|
52 |
|
sl@0
|
53 |
//____________________________________________________________________________//
|
sl@0
|
54 |
|
sl@0
|
55 |
#define BOOST_RTTI_SWITCH( type_id_ ) if( ::boost::rtti::id_t switch_by_id = type_id_ )
|
sl@0
|
56 |
#define BOOST_RTTI_CASE( type ) if( switch_by_id == ::boost::rtti::type_id<type>() )
|
sl@0
|
57 |
|
sl@0
|
58 |
//____________________________________________________________________________//
|
sl@0
|
59 |
|
sl@0
|
60 |
} // namespace rtti
|
sl@0
|
61 |
|
sl@0
|
62 |
} // namespace boost
|
sl@0
|
63 |
|
sl@0
|
64 |
// ************************************************************************** //
|
sl@0
|
65 |
// Revision History:
|
sl@0
|
66 |
//
|
sl@0
|
67 |
// $Log: rtti.hpp,v $
|
sl@0
|
68 |
// Revision 1.2 2005/05/15 06:45:32 rogeeff
|
sl@0
|
69 |
// *** empty log message ***
|
sl@0
|
70 |
//
|
sl@0
|
71 |
// Revision 1.1 2005/04/12 06:48:12 rogeeff
|
sl@0
|
72 |
// Runtime.Param library initial commit
|
sl@0
|
73 |
//
|
sl@0
|
74 |
// ************************************************************************** //
|
sl@0
|
75 |
|
sl@0
|
76 |
#endif // BOOST_RT_RTTI_HPP_062604GER
|