Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 1 | /* -*- 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 Shi | 408a700 | 2014-02-12 17:53:47 -0700 | [diff] [blame] | 11 | #include "strategy-info-host.hpp" |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 12 | |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 13 | namespace nfd { |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 14 | namespace 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 Shi | 408a700 | 2014-02-12 17:53:47 -0700 | [diff] [blame] | 22 | class FaceRecord : public StrategyInfoHost |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 23 | { |
| 24 | public: |
| 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 Afanasyev | eb3197f | 2014-03-17 19:28:18 -0700 | [diff] [blame^] | 36 | time::steady_clock::TimePoint |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 37 | getLastRenewed() const; |
| 38 | |
| 39 | /** \brief gives the time point this record expires |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 40 | * \return getLastRenewed() + InterestLifetime |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 41 | */ |
Alexander Afanasyev | eb3197f | 2014-03-17 19:28:18 -0700 | [diff] [blame^] | 42 | time::steady_clock::TimePoint |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 43 | getExpiry() const; |
| 44 | |
| 45 | /// updates lastNonce, lastRenewed, expiry fields |
| 46 | void |
| 47 | update(const Interest& interest); |
| 48 | |
| 49 | private: |
| 50 | shared_ptr<Face> m_face; |
| 51 | uint32_t m_lastNonce; |
Alexander Afanasyev | eb3197f | 2014-03-17 19:28:18 -0700 | [diff] [blame^] | 52 | time::steady_clock::TimePoint m_lastRenewed; |
| 53 | time::steady_clock::TimePoint m_expiry; |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | inline shared_ptr<Face> |
| 57 | FaceRecord::getFace() const |
| 58 | { |
| 59 | return m_face; |
| 60 | } |
| 61 | |
| 62 | inline uint32_t |
| 63 | FaceRecord::getLastNonce() const |
| 64 | { |
| 65 | return m_lastNonce; |
| 66 | } |
| 67 | |
Alexander Afanasyev | eb3197f | 2014-03-17 19:28:18 -0700 | [diff] [blame^] | 68 | inline time::steady_clock::TimePoint |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 69 | FaceRecord::getLastRenewed() const |
| 70 | { |
| 71 | return m_lastRenewed; |
| 72 | } |
| 73 | |
Alexander Afanasyev | eb3197f | 2014-03-17 19:28:18 -0700 | [diff] [blame^] | 74 | inline time::steady_clock::TimePoint |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 75 | FaceRecord::getExpiry() const |
| 76 | { |
| 77 | return m_expiry; |
| 78 | } |
| 79 | |
| 80 | } // namespace pit |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 81 | } // namespace nfd |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 82 | |
| 83 | #endif // NFD_TABLE_PIT_FACE_RECORD_HPP |