table: ContentStore enumeration
refs #2254
Change-Id: Ic440afea2197f12f7720adb559b836d08e864bed
diff --git a/daemon/table/cs-entry.cpp b/daemon/table/cs-entry.cpp
index 584dda3..d4f3921 100644
--- a/daemon/table/cs-entry.cpp
+++ b/daemon/table/cs-entry.cpp
@@ -28,91 +28,38 @@
namespace nfd {
namespace cs {
-Entry::Entry(const Name& name)
- : m_queryName(name)
+void
+Entry::setData(shared_ptr<const Data> data, bool isUnsolicited)
{
- BOOST_ASSERT(this->isQuery());
-}
+ m_data = data;
+ m_isUnsolicited = isUnsolicited;
-Entry::Entry(shared_ptr<const Data> data, bool isUnsolicited)
- : queueType(Cs::QUEUE_NONE)
- , m_data(data)
- , m_isUnsolicited(isUnsolicited)
-{
- BOOST_ASSERT(!this->isQuery());
-}
-
-bool
-Entry::isQuery() const
-{
- return m_data == nullptr;
-}
-
-shared_ptr<const Data>
-Entry::getData() const
-{
- BOOST_ASSERT(!this->isQuery());
- return m_data;
-}
-
-const Name&
-Entry::getName() const
-{
- BOOST_ASSERT(!this->isQuery());
- return m_data->getName();
-}
-
-const Name&
-Entry::getFullName() const
-{
- BOOST_ASSERT(!this->isQuery());
- return m_data->getFullName();
-}
-
-bool
-Entry::canStale() const
-{
- BOOST_ASSERT(!this->isQuery());
- return m_data->getFreshnessPeriod() >= time::milliseconds::zero();
+ updateStaleTime();
}
bool
Entry::isStale() const
{
- BOOST_ASSERT(!this->isQuery());
- return time::steady_clock::now() > m_staleAt;
+ BOOST_ASSERT(this->hasData());
+ return m_staleTime < time::steady_clock::now();
}
void
-Entry::refresh()
+Entry::updateStaleTime()
{
- BOOST_ASSERT(!this->isQuery());
- if (this->canStale()) {
- m_staleAt = time::steady_clock::now() + time::milliseconds(m_data->getFreshnessPeriod());
+ BOOST_ASSERT(this->hasData());
+ if (m_data->getFreshnessPeriod() >= time::milliseconds::zero()) {
+ m_staleTime = time::steady_clock::now() + time::milliseconds(m_data->getFreshnessPeriod());
}
else {
- m_staleAt = time::steady_clock::TimePoint::max();
+ m_staleTime = time::steady_clock::TimePoint::max();
}
}
bool
-Entry::isUnsolicited() const
-{
- BOOST_ASSERT(!this->isQuery());
- return m_isUnsolicited;
-}
-
-void
-Entry::unsetUnsolicited()
-{
- BOOST_ASSERT(!this->isQuery());
- m_isUnsolicited = false;
-}
-
-bool
Entry::canSatisfy(const Interest& interest) const
{
- BOOST_ASSERT(!this->isQuery());
+ BOOST_ASSERT(this->hasData());
if (!interest.matchesData(*m_data)) {
return false;
}
@@ -124,25 +71,12 @@
return true;
}
-bool
-Entry::operator<(const Entry& other) const
+void
+Entry::reset()
{
- if (this->isQuery()) {
- if (other.isQuery()) {
- return m_queryName < other.m_queryName;
- }
- else {
- return m_queryName < other.m_queryName;
- }
- }
- else {
- if (other.isQuery()) {
- return this->getFullName() < other.m_queryName;
- }
- else {
- return this->getFullName() < other.getFullName();
- }
- }
+ m_data.reset();
+ m_isUnsolicited = false;
+ m_staleTime = time::steady_clock::TimePoint();
}
} // namespace cs