table: rename cs::iterator to cs::Table::const_iterator
refs #4914
Change-Id: I0d81a0983c6bbf8ad2bdf78eec4f37ac73ec3d2d
diff --git a/daemon/table/cs-policy.hpp b/daemon/table/cs-policy.hpp
index f50f854..fb59990 100644
--- a/daemon/table/cs-policy.hpp
+++ b/daemon/table/cs-policy.hpp
@@ -71,8 +71,6 @@
return m_policyName;
}
-
-public:
/** \brief gets cs
*/
Cs*
@@ -106,12 +104,18 @@
void
setLimit(size_t nMaxEntries);
+public:
+ /** \brief a reference to an CS entry
+ * \note operator< of EntryRef compares the Data name enclosed in the Entry.
+ */
+ using EntryRef = Table::const_iterator;
+
/** \brief emits when an entry is being evicted
*
- * A policy implementation should emit this signal to cause CS to erase the entry from its index.
+ * A policy implementation should emit this signal to cause CS to erase an entry from its index.
* CS should connect to this signal and erase the entry upon signal emission.
*/
- signal::Signal<Policy, iterator> beforeEvict;
+ signal::Signal<Policy, EntryRef> beforeEvict;
/** \brief invoked by CS after a new entry is inserted
* \post cs.size() <= getLimit()
@@ -120,27 +124,27 @@
* During this process, \p i might be evicted.
*/
void
- afterInsert(iterator i);
+ afterInsert(EntryRef i);
/** \brief invoked by CS after an existing entry is refreshed by same Data
*
* The policy may witness this refresh to make better eviction decisions in the future.
*/
void
- afterRefresh(iterator i);
+ afterRefresh(EntryRef i);
/** \brief invoked by CS before an entry is erased due to management command
* \warning CS must not invoke this method if an entry is erased due to eviction.
*/
void
- beforeErase(iterator i);
+ beforeErase(EntryRef i);
/** \brief invoked by CS before an entry is used to match a lookup
*
* The policy may witness this usage to make better eviction decisions in the future.
*/
void
- beforeUse(iterator i);
+ beforeUse(EntryRef i);
protected:
/** \brief invoked after a new entry is created in CS
@@ -152,7 +156,7 @@
* in order to keep CS size under limit.
*/
virtual void
- doAfterInsert(iterator i) = 0;
+ doAfterInsert(EntryRef i) = 0;
/** \brief invoked after an existing entry is refreshed by same Data
*
@@ -160,7 +164,7 @@
* and adjust its cleanup index.
*/
virtual void
- doAfterRefresh(iterator i) = 0;
+ doAfterRefresh(EntryRef i) = 0;
/** \brief invoked before an entry is erased due to management command
* \note This will not be invoked for an entry being evicted by policy.
@@ -169,7 +173,7 @@
* from its cleanup index without emitted \p afterErase signal.
*/
virtual void
- doBeforeErase(iterator i) = 0;
+ doBeforeErase(EntryRef i) = 0;
/** \brief invoked before an entry is used to match a lookup
*
@@ -177,7 +181,7 @@
* and adjust its cleanup index.
*/
virtual void
- doBeforeUse(iterator i) = 0;
+ doBeforeUse(EntryRef i) = 0;
/** \brief evicts zero or more entries
* \post CS size does not exceed hard limit
@@ -189,8 +193,8 @@
DECLARE_SIGNAL_EMIT(beforeEvict)
private: // registry
- typedef std::function<unique_ptr<Policy>()> CreateFunc;
- typedef std::map<std::string, CreateFunc> Registry; // indexed by policy name
+ using CreateFunc = std::function<unique_ptr<Policy>()>;
+ using Registry = std::map<std::string, CreateFunc>; // indexed by policy name
static Registry&
getRegistry();