00001 /*-----------------------------------------------------------------------* 00002 Project: Nintendo Augmented Reality Library. 00003 File: narFlags.h 00004 00005 Copyright (C)2011-2012 Nintendo Co., Ltd. All rights reserved. 00006 00007 These coded instructions, statements, and computer programs contain 00008 proprietary information of Nintendo and/or its licensed developers 00009 and are protected by national and international copyright laws. They 00010 may not be disclosed to third parties or copied or duplicated in any 00011 form, in whole or in part, without the prior written consent of 00012 Nintendo. 00013 The content herein is highly confidential and should be handled 00014 accordingly. 00015 *-----------------------------------------------------------------------*/ 00016 00022 #ifndef NAR_FLAGS_H__ 00023 #define NAR_FLAGS_H__ 00024 00025 namespace mw { namespace nar 00026 { 00031 template < typename T, typename F > 00032 class Flags_tc 00033 { 00034 public: 00035 Flags_tc() 00036 : m_Flags( static_cast< T >( 0 ) ) 00037 {} 00038 00041 void Clear() 00042 { 00043 m_Flags = static_cast< T >( 0 ); 00044 } 00045 00048 void TurnOn( F flags ) 00049 { 00050 m_Flags = static_cast< T >( static_cast< int >( m_Flags ) | static_cast< int >( flags ) ); 00051 } 00052 00055 void TurnOff( F flags ) 00056 { 00057 m_Flags = static_cast< T >( static_cast< int >( m_Flags ) & ~static_cast< int >( flags ) ); 00058 } 00059 00062 void Toggle( F flags ) 00063 { 00064 m_Flags = static_cast< T >( static_cast< int >( m_Flags ) ^ static_cast< int >( flags ) ); 00065 } 00066 00069 void Set( bool b, F flags ) 00070 { 00071 if ( b ) TurnOn( flags ); 00072 else TurnOff( flags ); 00073 } 00074 00077 bool IsAnyOn( F flags ) const 00078 { 00079 return ( m_Flags & flags ) != 0; 00080 } 00081 00084 bool IsAllOn( F flags ) const 00085 { 00086 return ( m_Flags & flags ) == flags; 00087 } 00088 private: 00089 T m_Flags; 00090 }; 00091 } 00092 } 00093 00098 #define NAR_EFLAG( x ) x, x##_false_bottom_ = ( (int)x << 1 ) -1 00099 00100 #endif
© 2011-2012 Nintendo. All rights reserved.
CONFIDENTIAL