table: mock Measurements table
refs #1259, #1197
Change-Id: Ie7cd2ff6fbbb413a77539eb9f1c5354405252cec
diff --git a/daemon/table/measurements.hpp b/daemon/table/measurements.hpp
new file mode 100644
index 0000000..2e3a88c
--- /dev/null
+++ b/daemon/table/measurements.hpp
@@ -0,0 +1,85 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (C) 2014 Named Data Networking Project
+ * See COPYING for copyright and distribution information.
+ */
+
+#ifndef NFD_TABLE_MEASUREMENTS_HPP
+#define NFD_TABLE_MEASUREMENTS_HPP
+
+#include "measurements-entry.hpp"
+#include "core/time.hpp"
+
+namespace nfd {
+
+namespace fib {
+class Entry;
+}
+namespace pit {
+class Entry;
+}
+
+/** \class Measurement
+ * \brief represents the Measurements table
+ */
+class Measurements : noncopyable
+{
+public:
+ explicit
+ Measurements(boost::asio::io_service& ioService);
+
+ ~Measurements();
+
+ /// find or insert a Measurements entry for name
+ shared_ptr<measurements::Entry>
+ get(const Name& name);
+
+ /// find or insert a Measurements entry for fibEntry->getPrefix()
+ shared_ptr<measurements::Entry>
+ get(const fib::Entry& fibEntry);
+
+ /// find or insert a Measurements entry for pitEntry->getName()
+ shared_ptr<measurements::Entry>
+ get(const pit::Entry& pitEntry);
+
+ /** \brief find or insert a Measurements entry for child's parent
+ *
+ * If child is the root entry, returns null.
+ */
+ shared_ptr<measurements::Entry>
+ getParent(shared_ptr<measurements::Entry> child);
+
+// /// perform a longest prefix match
+// shared_ptr<fib::Entry>
+// findLongestPrefixMatch(const Name& name) const;
+//
+// /// perform an exact match
+// shared_ptr<fib::Entry>
+// findExactMatch(const Name& name) const;
+
+ /** \brief extend lifetime of an entry
+ *
+ * The entry will be kept until at least now()+lifetime.
+ */
+ void
+ extendLifetime(measurements::Entry& entry, time::Duration lifetime);
+
+private:
+ void
+ extendLifetimeInternal(
+ std::map<Name, shared_ptr<measurements::Entry> >::iterator it,
+ time::Duration lifetime);
+
+ void
+ cleanup(std::map<Name, shared_ptr<measurements::Entry> >::iterator it);
+
+private:
+ std::map<Name, shared_ptr<measurements::Entry> > m_table;
+
+ Scheduler m_scheduler;
+ static const time::Duration s_defaultLifetime;
+};
+
+} // namespace nfd
+
+#endif // NFD_TABLE_MEASUREMENTS_HPP