fw: Strategy base class

refs #1254

Change-Id: I9b533dd8bda131ae060f9e9f8cb2dd96541a8e60
diff --git a/daemon/fw/strategy.cpp b/daemon/fw/strategy.cpp
index f8c2f12..dd7eab5 100644
--- a/daemon/fw/strategy.cpp
+++ b/daemon/fw/strategy.cpp
@@ -6,10 +6,13 @@
 
 #include "strategy.hpp"
 #include "forwarder.hpp"
+#include "core/logger.hpp"
 
 namespace nfd {
 namespace fw {
 
+NFD_LOG_INIT("Strategy");
+
 Strategy::Strategy(Forwarder& forwarder)
   : m_forwarder(forwarder)
 {
@@ -19,6 +22,29 @@
 {
 }
 
+void
+Strategy::beforeExpirePendingInterest(shared_ptr<pit::Entry> pitEntry)
+{
+  NFD_LOG_DEBUG("beforeExpirePendingInterest pitEntry=" << pitEntry->getName());
+}
+
+void
+Strategy::afterAddFibEntry(shared_ptr<fib::Entry> fibEntry)
+{
+  NFD_LOG_DEBUG("afterAddFibEntry fibEntry=" << fibEntry->getPrefix());
+}
+
+void
+Strategy::afterUpdateFibEntry(shared_ptr<fib::Entry> fibEntry)
+{
+  NFD_LOG_DEBUG("afterUpdateFibEntry fibEntry=" << fibEntry->getPrefix());
+}
+
+void
+Strategy::beforeRemoveFibEntry(shared_ptr<fib::Entry> fibEntry)
+{
+  NFD_LOG_DEBUG("beforeRemoveFibEntry fibEntry=" << fibEntry->getPrefix());
+}
 
 void
 Strategy::sendInterest(shared_ptr<pit::Entry> pitEntry,
diff --git a/daemon/fw/strategy.hpp b/daemon/fw/strategy.hpp
index ce21c13..027acdf 100644
--- a/daemon/fw/strategy.hpp
+++ b/daemon/fw/strategy.hpp
@@ -33,23 +33,61 @@
   virtual
   ~Strategy();
   
+public: // triggers
+  /** \brief trigger after Interest is received
+   *
+   *  The Interest:
+   *  - does not violate Scope
+   *  - is not looped
+   *  - cannot be satisfied by ContentStore
+   *  - is under a namespace managed by this strategy
+   *
+   *  The strategy should decide whether and where to forward this Interest.
+   *  - If the strategy decides to forward this Interest,
+   *    invoke this->sendInterest one or more times, either now or shortly after
+   *  - If strategy concludes that this Interest cannot be forwarded,
+   *    invoke this->rebuffPendingInterest so that PIT entry will be deleted shortly
+   */
   virtual void
   afterReceiveInterest(const Face& inFace,
                        const Interest& interest,
                        shared_ptr<fib::Entry> fibEntry,
                        shared_ptr<pit::Entry> pitEntry) =0;
   
-  //virtual void
-  //beforeExpirePendingInterest() =0;
+  /** \brief trigger before PIT entry expires
+   *
+   *  PIT entry expires when InterestLifetime has elapsed for all InRecords,
+   *  and it is not satisfied by an incoming Data.
+   *
+   *  This trigger is not invoked for PIT entry already satisfied.
+   *
+   *  In this base class this method does nothing.
+   */
+  virtual void
+  beforeExpirePendingInterest(shared_ptr<pit::Entry> pitEntry);
   
-  //virtual void
-  //afterAddFibEntry() =0;
+  /** \brief trigger after FIB entry is being inserted
+   *         and becomes managed by this strategy
+   *
+   *  In this base class this method does nothing.
+   */
+  virtual void
+  afterAddFibEntry(shared_ptr<fib::Entry> fibEntry);
   
-  //virtual void
-  //afterUpdateFibEntry() =0;
+  /** \brief trigger after FIB entry being managed by this strategy is updated
+   *
+   *  In this base class this method does nothing.
+   */
+  virtual void
+  afterUpdateFibEntry(shared_ptr<fib::Entry> fibEntry);
   
-  //virtual void
-  //beforeRemoveFibEntry() =0;
+  /** \brief trigger before FIB entry ceises to be managed by this strategy
+   *         or is being deleted
+   *
+   *  In this base class this method does nothing.
+   */
+  virtual void
+  beforeRemoveFibEntry(shared_ptr<fib::Entry> fibEntry);
   
 protected: // actions
   /// send Interest to outFace
@@ -58,6 +96,7 @@
                     shared_ptr<Face> outFace);
   
   /** \brief decide that a pending Interest cannot be forwarded
+   *
    *  This shall not be called if the pending Interest has been
    *  forwarded earlier, and does not need to be resent now.
    */
@@ -65,6 +104,10 @@
   rebuffPendingInterest(shared_ptr<pit::Entry> pitEntry);
   
 private:
+  /** \brief reference to the forwarder
+   *
+   *  Triggers can access forwarder indirectly via actions.
+   */
   Forwarder& m_forwarder;
 };