blob: 4c6d946b2ceb841aa4447255f1aa5894916c26da [file] [log] [blame]
Junxiao Shi65d00722014-02-17 10:50:20 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (C) 2014 Named Data Networking Project
4 * See COPYING for copyright and distribution information.
5 */
6
7#ifndef NFD_TABLE_MEASUREMENTS_HPP
8#define NFD_TABLE_MEASUREMENTS_HPP
9
10#include "measurements-entry.hpp"
Junxiao Shidbe71732014-02-21 22:23:28 -070011#include "fib-entry.hpp"
12#include "pit-entry.hpp"
Junxiao Shi65d00722014-02-17 10:50:20 -070013#include "core/time.hpp"
14
15namespace nfd {
16
Junxiao Shi65d00722014-02-17 10:50:20 -070017/** \class Measurement
18 * \brief represents the Measurements table
19 */
20class Measurements : noncopyable
21{
22public:
Junxiao Shic041ca32014-02-25 20:01:15 -070023 Measurements();
Junxiao Shi65d00722014-02-17 10:50:20 -070024
25 ~Measurements();
26
27 /// find or insert a Measurements entry for name
28 shared_ptr<measurements::Entry>
29 get(const Name& name);
30
31 /// find or insert a Measurements entry for fibEntry->getPrefix()
32 shared_ptr<measurements::Entry>
33 get(const fib::Entry& fibEntry);
34
35 /// find or insert a Measurements entry for pitEntry->getName()
36 shared_ptr<measurements::Entry>
37 get(const pit::Entry& pitEntry);
38
39 /** \brief find or insert a Measurements entry for child's parent
40 *
41 * If child is the root entry, returns null.
42 */
43 shared_ptr<measurements::Entry>
44 getParent(shared_ptr<measurements::Entry> child);
45
46// /// perform a longest prefix match
47// shared_ptr<fib::Entry>
48// findLongestPrefixMatch(const Name& name) const;
49//
50// /// perform an exact match
51// shared_ptr<fib::Entry>
52// findExactMatch(const Name& name) const;
53
54 /** \brief extend lifetime of an entry
55 *
56 * The entry will be kept until at least now()+lifetime.
57 */
58 void
Junxiao Shidbe71732014-02-21 22:23:28 -070059 extendLifetime(measurements::Entry& entry, const time::Duration& lifetime);
Junxiao Shi65d00722014-02-17 10:50:20 -070060
61private:
62 void
63 extendLifetimeInternal(
64 std::map<Name, shared_ptr<measurements::Entry> >::iterator it,
Junxiao Shidbe71732014-02-21 22:23:28 -070065 const time::Duration& lifetime);
Junxiao Shi65d00722014-02-17 10:50:20 -070066
67 void
68 cleanup(std::map<Name, shared_ptr<measurements::Entry> >::iterator it);
69
70private:
71 std::map<Name, shared_ptr<measurements::Entry> > m_table;
72
Junxiao Shi65d00722014-02-17 10:50:20 -070073 static const time::Duration s_defaultLifetime;
74};
75
76} // namespace nfd
77
78#endif // NFD_TABLE_MEASUREMENTS_HPP