YSTest  PreAlpha_b500_20140530
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
ycounter.hpp
浏览该文件的文档.
1 /*
2  © 2010-2014 FrankHB.
3 
4  This file is part of the YSLib project, and may only be used,
5  modified, and distributed under the terms of the YSLib project
6  license, LICENSE.TXT. By continuing to use, modify, or distribute
7  this file you indicate that you have read the license and
8  understand and accept it fully.
9 */
10 
28 #ifndef YSL_INC_Core_ycounter_hpp_
29 #define YSL_INC_Core_ycounter_hpp_ 1
30 
31 #include "YModules.h"
32 #include YFM_YSLib_Core_YShellDefinition
33 
34 namespace YSLib
35 {
36 
41 template<class _type, typename count_t = u32>
42 class GMCounter
43 {
44 private:
45  static count_t nCount, nTotal;
47 
48 public:
55  : nID(nCount++)
56  {
57  ++nTotal;
58  }
64  inline
66  : nID(nCount++)
67  {
68  ++nTotal;
69  }
75 
76 protected:
82  ~GMCounter()
83  {
84  --nTotal;
85  }
86 
87 public:
89 
90  static DefGetter(ynothrow, count_t, Count, nCount)
93  yconstfn DefGetter(const ynothrow, count_t, ObjectID, nID)
94 
95 protected:
100  static void
101  ResetCount() ynothrow
102  {
103  nCount = 0;
104  }
105 
110  static void
111  ResetTotal() ynothrow
112  {
113  nTotal = 0;
114  }
115 
120  void
122  {
123  nID = 0;
124  }
125 };
126 
127 template<class _type, typename count_t>
129 
130 template<class _type, typename count_t>
132 
133 } // namespace YSLib;
134 
135 #endif
136 
count_t nID
实例标识序列号。
Definition: ycounter.hpp:46
DefDeMoveCtor(GMCounter) protected
转移构造。
Definition: ycounter.hpp:74
static DefGetter(ynothrow, count_t, Count, nCount) static DefGetter(ynothrow
复位实例生成计数。
Definition: ycounter.hpp:111
模板类实例计数器。
Definition: ycounter.hpp:42
void ResetID() ynothrow
复位实例标识序列号。
Definition: ycounter.hpp:121
static count_t nTotal
实例生成计数和实例计数。
Definition: ycounter.hpp:45
#define ynothrow
YSLib 无异常抛出保证:若支持 noexcept 关键字, 指定特定的 noexcept 异常规范。
Definition: ydef.h:514
GMCounter(const GMCounter &) ynothrow
复制构造。
Definition: ycounter.hpp:65
GMCounter() ynothrow
构造。
Definition: ycounter.hpp:54
#define yconstfn
指定编译时常量函数。
Definition: ydef.h:463
static count_t nCount
Definition: ycounter.hpp:45