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" |
| 11 | #include "core/time.hpp" |
| 12 | |
| 13 | namespace ndn { |
| 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 | */ |
| 22 | class FaceRecord |
| 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 | |
| 36 | time::Point |
| 37 | getLastRenewed() const; |
| 38 | |
| 39 | /** \brief gives the time point this record expires |
| 40 | * \return{ getLastRenewed() + InterestLifetime } |
| 41 | */ |
| 42 | time::Point |
| 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; |
| 52 | time::Point m_lastRenewed; |
| 53 | time::Point m_expiry; |
| 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 | |
| 68 | inline time::Point |
| 69 | FaceRecord::getLastRenewed() const |
| 70 | { |
| 71 | return m_lastRenewed; |
| 72 | } |
| 73 | |
| 74 | inline time::Point |
| 75 | FaceRecord::getExpiry() const |
| 76 | { |
| 77 | return m_expiry; |
| 78 | } |
| 79 | |
| 80 | } // namespace pit |
| 81 | } // namespace ndn |
| 82 | |
| 83 | #endif // NFD_TABLE_PIT_FACE_RECORD_HPP |