1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: Handle.h 4 Copyright (C)2009 Nintendo Co., Ltd. All rights reserved. 5 These coded instructions, statements, and computer programs contain 6 proprietary information of Nintendo of America Inc. and/or Nintendo 7 Company Ltd., and are protected by Federal copyright law. They may 8 not be disclosed to third parties or copied or duplicated in any form, 9 in whole or in part, without the prior written consent of Nintendo. 10 $Rev: 13429 $ 11 *--------------------------------------------------------------------------- 12 13 14 */ 15 16 /* Please see man pages for details 17 18 19 20 */ 21 22 #ifndef NN_HANDLE_H_ 23 #define NN_HANDLE_H_ 24 25 #include <nn/types.h> 26 #include <nn/Result.h> 27 28 29 //------------------------------------------------------------------- 30 // for C / C++ 31 32 /* Please see man pages for details 33 34 35 36 */ 37 38 /* Please see man pages for details 39 40 41 42 43 44 */ 45 46 #ifdef __cplusplus 47 extern "C" { 48 #endif // ifdef __cplusplus 49 50 /* Please see man pages for details 51 52 */ 53 typedef struct nnHandle 54 { 55 bit32 value; 56 } 57 nnHandle; 58 59 extern const nnHandle NN_INVALID_HANDLE_VALUE; 60 61 #ifdef __cplusplus 62 } 63 #endif // ifdef __cplusplus 64 65 /* 66 67 */ 68 /* 69 70 */ 71 72 73 //------------------------------------------------------------------- 74 // for C++ 75 76 #ifdef __cplusplus 77 78 namespace nn { 79 /* Please see man pages for details 80 81 */ 82 class Handle{ 83 public: Handle()84 Handle() : m_Handle(0) 85 { 86 } 87 Handle(nnHandle handle)88 Handle(nnHandle handle) : m_Handle(handle.value) 89 { 90 } 91 Handle(bit32 handle)92 explicit Handle(bit32 handle) 93 { 94 m_Handle = handle; 95 } 96 97 /* Please see man pages for details 98 99 100 101 */ IsValid()102 bool IsValid() const 103 { 104 return m_Handle != 0; 105 } 106 107 /* Please see man pages for details 108 109 110 111 */ 112 #if ! defined(NN_SWITCH_DISABLE_DEBUG_PRINT) || ! defined(NN_SWITCH_DISABLE_DEBUG_PRINT_FOR_SDK) GetPrintableBits()113 bit32 GetPrintableBits() const 114 { 115 return m_Handle; 116 } 117 #endif 118 119 bool operator ==(const Handle& rhs) const { return this->m_Handle == rhs.m_Handle; } 120 bool operator !=(const Handle& rhs) const { return this->m_Handle != rhs.m_Handle; } nnHandle()121 operator nnHandle() const { nnHandle handle = {this->m_Handle}; return handle; } 122 123 private: 124 bit32 m_Handle; 125 }; 126 127 namespace 128 { 129 const nnHandle PSEUDO_HANDLE_CURRENT_THREAD = {0xFFFF8000}; // 130 const nnHandle PSEUDO_HANDLE_CURRENT_PROCESS = {0xFFFF8001}; // 131 const nnHandle INVALID_HANDLE_VALUE = {0}; 132 } 133 134 } 135 #endif // ifdef __cplusplus 136 137 138 139 #endif /* NN_HANDLE_H_ */ 140