YSTest: ycounter.hpp 源文件

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;
46 count_t nID;
47
48 public:
54 GMCounter() ynothrow
55 : nID(nCount++)
56 {
57 ++nTotal;
58 }
64 inline
65 GMCounter(const GMCounter&) ynothrow
66 : nID(nCount++)
67 {
68 ++nTotal;
69 }
74 DefDeMoveCtor(GMCounter)
75
76 protected:
82 ~GMCounter()
83 {
84 --nTotal;
85 }
86
87 public:
89
90 static DefGetter(ynothrow, count_t, Count, nCount)
91 static DefGetter(ynothrow, count_t, Total, nTotal)
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
121 ResetID() ynothrow
122 {
123 nID = 0;
124 }
125 };
126
127 template<class _type, typename count_t>
128 count_t GMCounter<_type, count_t>::nCount(0);
129
130 template<class _type, typename count_t>
131 count_t GMCounter<_type, count_t>::nTotal(0);
132
133 } // namespace YSLib;
134
135 #endif
136
YSLib::GMCounter::nID
count_t nID
实例标识序列号。
Definition: ycounter.hpp:46
YModules.h
YSLib::GMCounter::DefDeMoveCtor
DefDeMoveCtor(GMCounter) protected
转移构造。
Definition: ycounter.hpp:74
YSLib::GMCounter::DefGetter
static DefGetter(ynothrow, count_t, Count, nCount) static DefGetter(ynothrow
复位实例生成计数。
Definition: ycounter.hpp:111
YSLib::GMCounter
模板类实例计数器。
Definition: ycounter.hpp:42
YSLib::GMCounter::ResetID
void ResetID() ynothrow
复位实例标识序列号。
Definition: ycounter.hpp:121
YSLib::GMCounter::nTotal
static count_t nTotal
实例生成计数和实例计数。
Definition: ycounter.hpp:45
YSLib::GMCounter::count_t
static count_t
Definition: ycounter.hpp:91
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:514
YSLib::GMCounter::GMCounter
GMCounter(const GMCounter &) ynothrow
复制构造。
Definition: ycounter.hpp:65
YSLib::GMCounter::GMCounter
GMCounter() ynothrow
构造。
Definition: ycounter.hpp:54
yconstfn
#define yconstfn
指定编译时常量函数。
Definition: ydef.h:463
YSLib::GMCounter::nCount
static count_t nCount
Definition: ycounter.hpp:45
YSLib::GMCounter::Total
static Total
Definition: ycounter.hpp:91