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" |
Junxiao Shi | 408a700 | 2014-02-12 17:53:47 -0700 | [diff] [blame] | 12 | #include "strategy-info-host.hpp" |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 13 | |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 14 | namespace nfd { |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 15 | namespace pit { |
| 16 | |
| 17 | /** \class FaceRecord |
| 18 | * \brief contains information about an Interest |
| 19 | * on an incoming or outgoing face |
| 20 | * \note This is an implementation detail to extract common functionality |
| 21 | * of InRecord and OutRecord |
| 22 | */ |
Junxiao Shi | 408a700 | 2014-02-12 17:53:47 -0700 | [diff] [blame] | 23 | class FaceRecord : public StrategyInfoHost |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 24 | { |
| 25 | public: |
| 26 | explicit |
| 27 | FaceRecord(shared_ptr<Face> face); |
| 28 | |
| 29 | FaceRecord(const FaceRecord& other); |
| 30 | |
| 31 | shared_ptr<Face> |
| 32 | getFace() const; |
| 33 | |
| 34 | uint32_t |
| 35 | getLastNonce() const; |
| 36 | |
| 37 | time::Point |
| 38 | getLastRenewed() const; |
| 39 | |
| 40 | /** \brief gives the time point this record expires |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame^] | 41 | * \return getLastRenewed() + InterestLifetime |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 42 | */ |
| 43 | time::Point |
| 44 | getExpiry() const; |
| 45 | |
| 46 | /// updates lastNonce, lastRenewed, expiry fields |
| 47 | void |
| 48 | update(const Interest& interest); |
| 49 | |
| 50 | private: |
| 51 | shared_ptr<Face> m_face; |
| 52 | uint32_t m_lastNonce; |
| 53 | time::Point m_lastRenewed; |
| 54 | time::Point m_expiry; |
| 55 | }; |
| 56 | |
| 57 | inline shared_ptr<Face> |
| 58 | FaceRecord::getFace() const |
| 59 | { |
| 60 | return m_face; |
| 61 | } |
| 62 | |
| 63 | inline uint32_t |
| 64 | FaceRecord::getLastNonce() const |
| 65 | { |
| 66 | return m_lastNonce; |
| 67 | } |
| 68 | |
| 69 | inline time::Point |
| 70 | FaceRecord::getLastRenewed() const |
| 71 | { |
| 72 | return m_lastRenewed; |
| 73 | } |
| 74 | |
| 75 | inline time::Point |
| 76 | FaceRecord::getExpiry() const |
| 77 | { |
| 78 | return m_expiry; |
| 79 | } |
| 80 | |
| 81 | } // namespace pit |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 82 | } // namespace nfd |
Junxiao Shi | cbba04c | 2014-01-26 14:21:22 -0700 | [diff] [blame] | 83 | |
| 84 | #endif // NFD_TABLE_PIT_FACE_RECORD_HPP |