table: ContentStore enumeration

refs #2254

Change-Id: Ic440afea2197f12f7720adb559b836d08e864bed
diff --git a/daemon/table/cs-entry.hpp b/daemon/table/cs-entry.hpp
index a35d9e9..fe7846c 100644
--- a/daemon/table/cs-entry.hpp
+++ b/daemon/table/cs-entry.hpp
@@ -26,81 +26,117 @@
 #ifndef NFD_DAEMON_TABLE_CS_ENTRY_HPP
 #define NFD_DAEMON_TABLE_CS_ENTRY_HPP
 
-#include "cs.hpp"
-#include "core/scheduler.hpp"
+#include "common.hpp"
 
 namespace nfd {
 namespace cs {
 
-/** \brief an Entry in ContentStore
- *  \note This type is internal to ContentStore.
- *
- *  An Entry is either a stored Entry which contains a Data packet and related attributes,
- *  or a query Entry which contains a Name that is LessComparable to other stored/query Entry
- *  and is used to lookup a container of entries.
+/** \brief represents a base class for CS entry
  */
 class Entry
 {
-public:
-  /** \brief construct Entry for query
-   *  \note Name is implicitly convertible to Entry, so that Name can be passed to
-   *        lookup functions on a container of Entry
+public: // exposed through ContentStore enumeration
+  /** \return the stored Data
+   *  \pre hasData()
    */
-  Entry(const Name& name);
+  const Data&
+  getData() const
+  {
+    BOOST_ASSERT(this->hasData());
+    return *m_data;
+  }
 
-  /** \brief construct Entry for storage
+  /** \return Name of the stored Data
+   *  \pre hasData()
    */
-  Entry(shared_ptr<const Data> data, bool isUnsolicited);
-
-  shared_ptr<const Data>
-  getData() const;
-
   const Name&
-  getName() const;
+  getName() const
+  {
+    BOOST_ASSERT(this->hasData());
+    return m_data->getName();
+  }
 
+  /** \return full name (including implicit digest) of the stored Data
+   *  \pre hasData()
+   */
   const Name&
-  getFullName() const;
+  getFullName() const
+  {
+    BOOST_ASSERT(this->hasData());
+    return m_data->getFullName();
+  }
 
-  /** \return true if entry can become stale, false if entry is never stale
+  /** \return whether the stored Data is unsolicited
+   *  \pre hasData()
    */
   bool
-  canStale() const;
+  isUnsolicited() const
+  {
+    BOOST_ASSERT(this->hasData());
+    return m_isUnsolicited;
+  }
 
+  /** \return the absolute time when the stored Data becomes expired
+   *  \retval time::steady_clock::TimePoint::max() if the stored Data never expires
+   *  \pre hasData()
+   */
+  const time::steady_clock::TimePoint&
+  getStaleTime() const
+  {
+    BOOST_ASSERT(this->hasData());
+    return m_staleTime;
+  }
+
+  /** \brief checks if the stored Data is stale now
+   *  \pre hasData()
+   */
   bool
   isStale() const;
 
-  void
-  refresh();
-
-  bool
-  isUnsolicited() const;
-
-  void
-  unsetUnsolicited();
-
-  /** \brief determines whether Interest can be satisified by this cached Data
+  /** \brief determines whether Interest can be satisified by the stored Data
    *  \note ChildSelector is not considered
+   *  \pre hasData()
    */
   bool
   canSatisfy(const Interest& interest) const;
 
+public: // used by generic ContentStore implementation
+  /** \return true if a Data packet is stored
+   */
   bool
-  operator<(const Entry& other) const;
+  hasData() const
+  {
+    return m_data != nullptr;
+  }
+
+  /** \brief replaces the stored Data
+   */
+  void
+  setData(shared_ptr<const Data> data, bool isUnsolicited);
+
+  /** \brief replaces the stored Data
+   */
+  void
+  setData(const Data& data, bool isUnsolicited)
+  {
+    this->setData(data.shared_from_this(), isUnsolicited);
+  }
+
+  /** \brief refreshes stale time relative to current time
+   */
+  void
+  updateStaleTime();
+
+  /** \brief clears the entry
+   *  \post !hasData()
+   */
+  void
+  reset();
 
 private:
-  bool
-  isQuery() const;
-
-public:
-  Cs::QueueType queueType;
-  Cs::QueueIt queueIt;
-  scheduler::EventId moveStaleEvent;
-
-private:
-  Name m_queryName;
   shared_ptr<const Data> m_data;
-  time::steady_clock::TimePoint m_staleAt;
   bool m_isUnsolicited;
+  time::steady_clock::TimePoint m_staleTime;
 };
 
 } // namespace cs