CTR-Pia  5.4.3
Game Communication Engine
 全て クラス ネームスペース 関数 変数 型定義 列挙型 列挙型の値 ページ
transport_Singleton.h
1 /*--------------------------------------------------------------------------------*
2  Copyright (C)Nintendo All rights reserved.
3 
4  These coded instructions, statements, and computer programs contain proprietary
5  information of Nintendo and/or its licensed developers and are protected by
6  national and international copyright laws. They may not be disclosed to third
7  parties or copied or duplicated in any form, in whole or in part, without the
8  prior written consent of Nintendo.
9 
10  The content herein is highly confidential and should be handled accordingly.
11  *--------------------------------------------------------------------------------*/
12 
13 
14 #pragma once
15 
16 #include <nn/pia/transport/transport_Definitions.h>
17 
18 #include <nn/pia/transport/transport_Api.h>
19 #include <nn/pia/common/common_Report.h>
20 #include <nn/pia/pia_Assert.h>
21 
22 
23 // このマクロは、シングルトンに対応する.cppファイルの冒頭付近に記入してください。
24 #define NN_PIA_TRANSPORT_SINGLETON_DEFINE(CLASSNAME) CLASSNAME* CLASSNAME::s_pInstance = NULL
25 
26 
27 // このマクロは、シングルトンに対応する.cppファイルで記入してください。
28 #define NN_PIA_TRANSPORT_SINGLETON_CREATE_INSTANCE_IMPL(CLASSNAME) \
29  \
30 nn::pia::Result CLASSNAME::CreateInstance(void) \
31  \
32 { \
33  if (!IsInitialized()) \
34  { \
35  PIA_RETURN_RESULT_WITH_REPORT(ResultNotInitialized, "PiaTransport is not initialized."); \
36  } \
37  if (!IsInSetupMode()) \
38  { \
39  PIA_RETURN_RESULT_WITH_REPORT(ResultInvalidState, "Singleton must be created between nn::pia::transport::BeginSetup() and nn::pia::transport::EndSetup().") \
40  } \
41  if (s_pInstance) \
42  { \
43  PIA_RETURN_RESULT_WITH_REPORT(ResultAlreadyExists, "Singleton is already created."); \
44  } \
45  \
46  /* RootObjectから派生させていれば、RootObject::new が使われ、*/ \
47  /* グローバルnewは使われないはず。 */ \
48  s_pInstance = new CLASSNAME(); \
49  PIA_ASSERT(PIA_IS_VALID_POINTER(s_pInstance)); \
50  \
51  return ResultSuccess(); \
52  \
53 }
54 
55 
56 // このマクロは、シングルトンに対応する.cppファイルで記入してください。
57 #define NN_PIA_TRANSPORT_SINGLETON_DESTROY_INSTANCE_IMPL(CLASSNAME) \
58  \
59 void CLASSNAME::DestroyInstance(void) \
60  \
61 { \
62  if (s_pInstance) \
63  { \
64  /* 本クラスはRootObjectから派生させているので、RootObject::delete が使われ、 */ \
65  /* グローバルdeleteは使われないはず。 */ \
66  delete s_pInstance; \
67  s_pInstance = NULL; \
68  } \
69  \
70 }
71 
72 
73 namespace nn
74 {
75 namespace pia
76 {
77 namespace transport
78 {
79 }
80 }
81 } // end of namespace nn::pia::transport