Junxiao Shi | d3c792f | 2014-01-30 00:46:13 -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_FW_STRATEGY_HPP |
| 8 | #define NFD_FW_STRATEGY_HPP |
| 9 | |
| 10 | #include "forwarder.hpp" |
| 11 | |
| 12 | namespace nfd { |
| 13 | |
| 14 | /** \class Strategy |
| 15 | * \brief represents a forwarding strategy |
| 16 | */ |
| 17 | class Strategy |
| 18 | { |
| 19 | public: |
| 20 | explicit |
| 21 | Strategy(Forwarder& fw); |
| 22 | |
| 23 | virtual |
| 24 | ~Strategy(); |
| 25 | |
| 26 | virtual void |
| 27 | afterReceiveInterest(const Face& inFace, |
| 28 | const Interest& interest, |
| 29 | shared_ptr<fib::Entry> fibEntry, |
| 30 | shared_ptr<pit::Entry> pitEntry, |
| 31 | pit::InRecordCollection::iterator pitInRecord |
| 32 | ) =0; |
| 33 | |
| 34 | //virtual void |
| 35 | //beforeExpirePendingInterest() =0; |
| 36 | |
| 37 | //virtual void |
| 38 | //afterAddFibEntry() =0; |
| 39 | |
| 40 | //virtual void |
| 41 | //afterUpdateFibEntry() =0; |
| 42 | |
| 43 | //virtual void |
| 44 | //beforeRemoveFibEntry() =0; |
| 45 | |
| 46 | protected: // actions |
| 47 | /// send Interest to outFace |
| 48 | void |
| 49 | sendInterest(shared_ptr<pit::Entry> pitEntry, |
| 50 | shared_ptr<Face> outFace); |
| 51 | |
| 52 | /** \brief decide that a pending Interest cannot be forwarded |
| 53 | * This shall not be called if the pending Interest has been |
| 54 | * forwarded earlier, and does not need to be resent now. |
| 55 | */ |
| 56 | void |
| 57 | rebuffPendingInterest(shared_ptr<pit::Entry> pitEntry); |
| 58 | |
| 59 | private: |
| 60 | Forwarder& m_fw; |
| 61 | }; |
| 62 | |
| 63 | } // namespace nfd |
| 64 | |
| 65 | #endif // NFD_FW_STRATEGY_HPP |