blob: 9bcfbed56731bc377a79349dfc2dcabffa120803 [file] [log] [blame]
Junxiao Shicbba04c2014-01-26 14:21:22 -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_PIT_FACE_RECORD_HPP
8#define NFD_TABLE_PIT_FACE_RECORD_HPP
9
10#include "face/face.hpp"
Junxiao Shi408a7002014-02-12 17:53:47 -070011#include "strategy-info-host.hpp"
Junxiao Shicbba04c2014-01-26 14:21:22 -070012
Alexander Afanasyev18bbf812014-01-29 01:40:23 -080013namespace nfd {
Junxiao Shicbba04c2014-01-26 14:21:22 -070014namespace pit {
15
16/** \class FaceRecord
17 * \brief contains information about an Interest
18 * on an incoming or outgoing face
19 * \note This is an implementation detail to extract common functionality
20 * of InRecord and OutRecord
21 */
Junxiao Shi408a7002014-02-12 17:53:47 -070022class FaceRecord : public StrategyInfoHost
Junxiao Shicbba04c2014-01-26 14:21:22 -070023{
24public:
25 explicit
26 FaceRecord(shared_ptr<Face> face);
27
28 FaceRecord(const FaceRecord& other);
29
30 shared_ptr<Face>
31 getFace() const;
32
33 uint32_t
34 getLastNonce() const;
35
Alexander Afanasyeveb3197f2014-03-17 19:28:18 -070036 time::steady_clock::TimePoint
Junxiao Shicbba04c2014-01-26 14:21:22 -070037 getLastRenewed() const;
38
39 /** \brief gives the time point this record expires
Junxiao Shif3c07812014-03-11 21:48:49 -070040 * \return getLastRenewed() + InterestLifetime
Junxiao Shicbba04c2014-01-26 14:21:22 -070041 */
Alexander Afanasyeveb3197f2014-03-17 19:28:18 -070042 time::steady_clock::TimePoint
Junxiao Shicbba04c2014-01-26 14:21:22 -070043 getExpiry() const;
44
45 /// updates lastNonce, lastRenewed, expiry fields
46 void
47 update(const Interest& interest);
48
49private:
50 shared_ptr<Face> m_face;
51 uint32_t m_lastNonce;
Alexander Afanasyeveb3197f2014-03-17 19:28:18 -070052 time::steady_clock::TimePoint m_lastRenewed;
53 time::steady_clock::TimePoint m_expiry;
Junxiao Shicbba04c2014-01-26 14:21:22 -070054};
55
56inline shared_ptr<Face>
57FaceRecord::getFace() const
58{
59 return m_face;
60}
61
62inline uint32_t
63FaceRecord::getLastNonce() const
64{
65 return m_lastNonce;
66}
67
Alexander Afanasyeveb3197f2014-03-17 19:28:18 -070068inline time::steady_clock::TimePoint
Junxiao Shicbba04c2014-01-26 14:21:22 -070069FaceRecord::getLastRenewed() const
70{
71 return m_lastRenewed;
72}
73
Alexander Afanasyeveb3197f2014-03-17 19:28:18 -070074inline time::steady_clock::TimePoint
Junxiao Shicbba04c2014-01-26 14:21:22 -070075FaceRecord::getExpiry() const
76{
77 return m_expiry;
78}
79
80} // namespace pit
Alexander Afanasyev18bbf812014-01-29 01:40:23 -080081} // namespace nfd
Junxiao Shicbba04c2014-01-26 14:21:22 -070082
83#endif // NFD_TABLE_PIT_FACE_RECORD_HPP