/*---------------------------------------------------------------------------* Project: Horizon File: util_SizedEnum.h Copyright (C)2009-2012 Nintendo Co., Ltd. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. $Rev: 46347 $ *---------------------------------------------------------------------------*/ #ifndef NN_UTIL_UTIL_SIZEDENUM_H_ #define NN_UTIL_UTIL_SIZEDENUM_H_ #include #include #ifdef __cplusplus namespace nn { namespace util { //--------------------------------------------------------------------------- // // // // // // // // // // //--------------------------------------------------------------------------- template class SizedEnum { private: typedef SizedEnum Self; // NN_STATIC_ASSERT(sizeof(EnumT) <= sizeof(StorageT)); private: StorageT m_EnumValue; public: //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- SizedEnum() {} //--------------------------------------------------------------------------- // // // // // //--------------------------------------------------------------------------- SizedEnum(EnumT e) { Set(e); } //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- operator EnumT() const { return Get(); } //--------------------------------------------------------------------------- // // // // // // // //--------------------------------------------------------------------------- Self& operator =(EnumT e) { Set(e); return *this; } //--------------------------------------------------------------------------- // // // // // //--------------------------------------------------------------------------- void Set(EnumT e) { m_EnumValue = static_cast(e); } //--------------------------------------------------------------------------- // // // // // //--------------------------------------------------------------------------- EnumT Get() const { return static_cast(m_EnumValue); } }; //--------------------------------------------------------------------------- // // // // // // // //--------------------------------------------------------------------------- template class SizedEnum1 : public SizedEnum { public: //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- SizedEnum1() : SizedEnum() {} //--------------------------------------------------------------------------- // // // // // //--------------------------------------------------------------------------- SizedEnum1(EnumT e) : SizedEnum(e) {} }; //--------------------------------------------------------------------------- // // // // // // // //--------------------------------------------------------------------------- template class SizedEnum2 : public SizedEnum { public: //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- SizedEnum2() : SizedEnum() {} //--------------------------------------------------------------------------- // // // // // //--------------------------------------------------------------------------- SizedEnum2(EnumT e) : SizedEnum(e) {} }; //--------------------------------------------------------------------------- // // // // // // // //--------------------------------------------------------------------------- template class SizedEnum4 : public SizedEnum { public: //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- SizedEnum4() : SizedEnum() {} //--------------------------------------------------------------------------- // // // // // //--------------------------------------------------------------------------- SizedEnum4(EnumT e) : SizedEnum(e) {} }; }} #endif // __cplusplus #endif /* NN_UTIL_UTIL_SIZEDENUM_H_ */