x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
rtti_policy.hpp - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\references\boost_1_35_0\boost\statechart\detail\rtti_policy.hpp
旋转
特效
属性
历史版本
#ifndef BOOST_STATECHART_DETAIL_RTTI_POLICY_HPP_INCLUDED #define BOOST_STATECHART_DETAIL_RTTI_POLICY_HPP_INCLUDED ////////////////////////////////////////////////////////////////////////////// // Copyright 2002-2006 Andreas Huber Doenni // Distributed under the Boost Software License, Version 1.0. (See accompany- // ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ////////////////////////////////////////////////////////////////////////////// #include
#include
// BOOST_MSVC #include
#include
// std::type_info #ifdef BOOST_MSVC // We permanently turn off the following level 4 warnings because users will // have to do so themselves anyway if we turn them back on # pragma warning( disable: 4511 ) // copy constructor could not be generated # pragma warning( disable: 4512 ) // assignment operator could not be generated #endif namespace boost { namespace statechart { namespace detail { ////////////////////////////////////////////////////////////////////////////// struct id_provider { const void * pCustomId_; #if defined( BOOST_ENABLE_ASSERT_HANDLER ) || !defined( NDEBUG ) const std::type_info * pCustomIdType_; #endif }; template< class MostDerived > struct id_holder { static id_provider idProvider_; }; template< class MostDerived > id_provider id_holder< MostDerived >::idProvider_; ////////////////////////////////////////////////////////////////////////////// struct rtti_policy { #ifdef BOOST_STATECHART_USE_NATIVE_RTTI class id_type { public: //////////////////////////////////////////////////////////////////////// explicit id_type( const std::type_info & id ) : id_( id ) {} bool operator==( id_type right ) const { return id_ == right.id_ != 0; } bool operator!=( id_type right ) const { return !( *this == right ); } bool operator<( id_type right ) const { return id_.before( right.id_ ) != 0; } bool operator>( id_type right ) const { return right < *this; } bool operator>=( id_type right ) const { return !( *this < right ); } bool operator<=( id_type right ) const { return !( right < *this ); } private: //////////////////////////////////////////////////////////////////////// const std::type_info & id_; }; typedef bool id_provider_type; // dummy #else typedef const void * id_type; typedef const id_provider * id_provider_type; #endif //////////////////////////////////////////////////////////////////////////// template< class Base > class rtti_base_type : public Base { public: //////////////////////////////////////////////////////////////////////// typedef rtti_policy::id_type id_type; id_type dynamic_type() const { #ifdef BOOST_STATECHART_USE_NATIVE_RTTI return id_type( typeid( *this ) ); #else return idProvider_; #endif } #ifndef BOOST_STATECHART_USE_NATIVE_RTTI template< typename CustomId > const CustomId * custom_dynamic_type_ptr() const { BOOST_ASSERT( ( idProvider_->pCustomId_ == 0 ) || ( *idProvider_->pCustomIdType_ == typeid( CustomId ) ) ); return static_cast< const CustomId * >( idProvider_->pCustomId_ ); } #endif protected: #ifdef BOOST_STATECHART_USE_NATIVE_RTTI rtti_base_type( id_provider_type ) {} //////////////////////////////////////////////////////////////////////// #if BOOST_WORKAROUND( __GNUC__, BOOST_TESTED_AT( 4 ) ) // We make the destructor virtual for GCC because with this compiler // there is currently no way to disable the "has virtual functions but // non-virtual destructor" warning on a class by class basis. Although // it can be done on the compiler command line with // -Wno-non-virtual-dtor, this is undesirable as this would also // suppress legitimate warnings for types that are not states. virtual ~rtti_base_type() {} #else ~rtti_base_type() {} #endif private: //////////////////////////////////////////////////////////////////////// // For typeid( *this ) to return a value that corresponds to the most- // derived type, we need to have a vptr. Since this type does not // contain any virtual functions we need to artificially declare one so. virtual void dummy() {} #else rtti_base_type( id_provider_type idProvider ) : idProvider_( idProvider ) { } ~rtti_base_type() {} private: //////////////////////////////////////////////////////////////////////// id_provider_type idProvider_; #endif }; //////////////////////////////////////////////////////////////////////////// template< class MostDerived, class Base > class rtti_derived_type : public Base { public: //////////////////////////////////////////////////////////////////////// static id_type static_type() { #ifdef BOOST_STATECHART_USE_NATIVE_RTTI return id_type( typeid( const MostDerived ) ); #else return &id_holder< MostDerived >::idProvider_; #endif } #ifndef BOOST_STATECHART_USE_NATIVE_RTTI template< class CustomId > static const CustomId * custom_static_type_ptr() { BOOST_ASSERT( ( id_holder< MostDerived >::idProvider_.pCustomId_ == 0 ) || ( *id_holder< MostDerived >::idProvider_.pCustomIdType_ == typeid( CustomId ) ) ); return static_cast< const CustomId * >( id_holder< MostDerived >::idProvider_.pCustomId_ ); } template< class CustomId > static void custom_static_type_ptr( const CustomId * pCustomId ) { #if defined( BOOST_ENABLE_ASSERT_HANDLER ) || !defined( NDEBUG ) id_holder< MostDerived >::idProvider_.pCustomIdType_ = &typeid( CustomId ); #endif id_holder< MostDerived >::idProvider_.pCustomId_ = pCustomId; } #endif protected: //////////////////////////////////////////////////////////////////////// ~rtti_derived_type() {} #ifdef BOOST_STATECHART_USE_NATIVE_RTTI rtti_derived_type() : Base( false ) {} #else rtti_derived_type() : Base( &id_holder< MostDerived >::idProvider_ ) {} #endif }; }; } // namespace detail } // namespace statechart } // namespace boost #endif
rtti_policy.hpp
网页地址
文件地址
上一页
7/8
下一页
下载
( 6 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.