CTR-Pia  5.4.3
Game Communication Engine
 全て クラス ネームスペース 関数 変数 型定義 列挙型 列挙型の値 ページ
common_ListBase.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/common/common_Definitions.h>
17 #include <nn/pia/common/common_ListNode.h>
18 
19 
20 namespace nn
21 {
22 namespace pia
23 {
24 namespace common
25 {
26 
27 
28 /*!
29  @cond PRIVATE
30  @brief リストの基底クラスです。
31  */
32 class ListBase : public nn::pia::common::RootObject
33 {
34 public:
35  /*!
36  @brief デフォルトコンストラクタです。
37  */
38  ListBase(void)
39  {
40  Init();
41  }
42 
43 
44  /*!
45  @brief リストに含まれている要素数を取得します。
46  @return リストに含まれている要素数。
47  */
48  uint32_t Size() const
49  {
50  return m_Size;
51  }
52 
53 
54  /*!
55  @brief リストが空かどうか判定します。
56  @return リストが空ならtrue。
57  */
58  bool IsEmpty() const
59  {
60  return (Size() == 0);
61  }
62 
63 
64 protected:
65  void Init();
66 
67  void InitListNode(ListNode* pNode)
68  {
69  pNode->InitListNode();
70  }
71 
72  void ClearNode();
73 
74  void InsertBeforeNode(ListNode* pBasis, ListNode* pNode);
75 
76  void InsertAfterNode(ListNode* pBasis, ListNode* pNode);
77 
78  void EraseNode(ListNode* pNode);
79 
80  bool IsIncludeNode(const ListNode* pNode) const;
81 
82 
83  void PushFrontNode(ListNode* pNode)
84  {
85  InsertAfterNode(&m_Terminator, pNode);
86  }
87 
88  void PushBackNode(ListNode* pNode)
89  {
90  InsertBeforeNode(&m_Terminator, pNode);
91  }
92 
93  ListNode* PopFrontNode();
94 
95  ListNode* PopBackNode();
96 
97 
98  ListNode* FrontNode() const
99  {
100  return (m_Size > 0) ? m_Terminator.m_pNext : NULL;
101  }
102 
103  ListNode* BackNode() const
104  {
105  return (m_Size > 0) ? m_Terminator.m_pPrev : NULL;
106  }
107 
108  void RotateNode(ListNode* pNode);
109 
110 
111  const ListNode* Terminator() const
112  {
113  return &m_Terminator;
114  }
115 
116 private:
117  // コピー禁止
118  ListBase(const ListBase& rhs);
119  ListBase& operator=(const ListBase& rhs);
120 
121 private:
122  ListNode m_Terminator;
123  uint32_t m_Size;
124 };
125 //! @endcond
126 }
127 }
128 } // end of namespace nn::pia::common