sl@0: // (C) Copyright Gennadiy Rozental 2005. sl@0: // Distributed under the Boost Software License, Version 1.0. sl@0: // (See accompanying file LICENSE_1_0.txt or copy at sl@0: // http://www.boost.org/LICENSE_1_0.txt) sl@0: sl@0: // See http://www.boost.org/libs/test for the library home page. sl@0: // sl@0: // File : $RCSfile: rtti.hpp,v $ sl@0: // sl@0: // Version : $Revision: 1.2 $ sl@0: // sl@0: // Description : simple facilities for accessing type information at runtime sl@0: // *************************************************************************** sl@0: sl@0: #ifndef BOOST_TEST_RTTI_HPP_062604GER sl@0: #define BOOST_TEST_RTTI_HPP_062604GER sl@0: sl@0: #include sl@0: sl@0: namespace boost { sl@0: sl@0: namespace rtti { sl@0: sl@0: // ************************************************************************** // sl@0: // ************** rtti::type_id ************** // sl@0: // ************************************************************************** // sl@0: sl@0: typedef std::ptrdiff_t id_t; sl@0: sl@0: namespace rtti_detail { sl@0: sl@0: template sl@0: struct rttid_holder { sl@0: static id_t id() { return reinterpret_cast( &inst() ); } sl@0: sl@0: private: sl@0: struct rttid {}; sl@0: sl@0: static rttid const& inst() { static rttid s_inst; return s_inst; } sl@0: }; sl@0: sl@0: } // namespace rtti_detail sl@0: sl@0: //____________________________________________________________________________// sl@0: sl@0: template sl@0: inline id_t sl@0: type_id() sl@0: { sl@0: return rtti_detail::rttid_holder::id(); sl@0: } sl@0: sl@0: //____________________________________________________________________________// sl@0: sl@0: #define BOOST_RTTI_SWITCH( type_id_ ) if( ::boost::rtti::id_t switch_by_id = type_id_ ) sl@0: #define BOOST_RTTI_CASE( type ) if( switch_by_id == ::boost::rtti::type_id() ) sl@0: sl@0: //____________________________________________________________________________// sl@0: sl@0: } // namespace rtti sl@0: sl@0: } // namespace boost sl@0: sl@0: // ************************************************************************** // sl@0: // Revision History: sl@0: // sl@0: // $Log: rtti.hpp,v $ sl@0: // Revision 1.2 2005/05/15 06:45:32 rogeeff sl@0: // *** empty log message *** sl@0: // sl@0: // Revision 1.1 2005/04/12 06:48:12 rogeeff sl@0: // Runtime.Param library initial commit sl@0: // sl@0: // ************************************************************************** // sl@0: sl@0: #endif // BOOST_RT_RTTI_HPP_062604GER