YSTest  PreAlpha_b500_20140530
The YSLib Test Project
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
AccessHistory.hpp
浏览该文件的文档.
1 /*
2  © 2013-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_Service_AccessHistory_hpp_
29 #define YSL_INC_Service_AccessHistory_hpp_ 1
30 
31 #include "YModules.h"
32 #include YFM_YSLib_Adaptor_YContainer // for list;
33 
34 namespace YSLib
35 {
36 
42 template<typename _type>
44 {
45 public:
47  using ValueType = _type;
49  using ListType = list<_type>;
50 
51 protected:
55  typename ListType::iterator itCurrent;
56 
57 public:
60  : lstRecord(), itCurrent(lstRecord.end())
61  {}
64 
65  DefPred(const, AtBegin, itCurrent == lstRecord.begin())
66  DefPred(const, AtEnd, itCurrent == lstRecord.end())
67 
68  DefGetter(const ynothrow, const ListType&, List, lstRecord)
69 
71  PDefH(void, Clear, )
72  ImplExpr(lstRecord.clear(), itCurrent = lstRecord.end())
73 
75  void
76  DropSubsequent()
77  {
78  lstRecord.erase(itCurrent, lstRecord.end());
79  itCurrent = lstRecord.end();
80  }
81 
83  template<typename... _tParams>
84  void
85  Emplace(_tParams&&... args)
86  {
87  lstRecord.emplace(itCurrent, yforward(args)...);
88  }
89 
98  _type
99  Switch(bool is_prev)
100  {
101  if(is_prev)
102  {
103  --itCurrent;
104  --itCurrent;
105  }
106 
107  auto ret(std::move(*itCurrent));
108 
109  lstRecord.erase(itCurrent++);
110  return ret;
111  }
112 };
113 
114 } // namespace YSLib;
115 
116 #endif
117 
ListType lstRecord
列表记录:项的列表。
GAccessList()
构造:迭代器指向记录末尾。
#define DefPred(_q, _n,...)
Definition: YBaseMacro.h:172
yconstfn const string _tParams && args
Definition: Loader.h:111
list< Bookmark > ListType
记录列表类型。
DefDeCopyCtor(GAccessList) DefDeMoveCtor(GAccessList) DefPred(const
#define yforward(_expr)
根据参数类型使用 std::forward 传递对应参数。
Definition: ydef.h:722
#define DefGetter(_q, _t, _n,...)
Definition: YBaseMacro.h:180
ListType::iterator itCurrent
迭代器:指示当前项在记录中的插入位置。
#define DefDeMoveCtor(_t)
Definition: YBaseMacro.h:141
#define ImplExpr(...)
Definition: YBaseMacro.h:93
#define ynothrow
YSLib 无异常抛出保证:若支持 noexcept 关键字, 指定特定的 noexcept 异常规范。
Definition: ydef.h:514
Bookmark ValueType
访问项:值类型。
访问列表。