<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Rakesh,<div class=""><br class=""></div><div class="">I have cc’d Junxiao here. He is one of the main developers of NFD and he should be able to let us know what would be the most appropriate way to do that.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class=""><br class=""><div class="">
<div class=""><div class=""><div class=""><span class="" style="float: none; display: inline !important;">Spyridon (Spyros) Mastorakis</span><br class=""><span class="" style="float: none; display: inline !important;">Personal Website: </span><a href="http://cs.ucla.edu/~mastorakis/" class="">http://cs.ucla.edu/~mastorakis/</a><br class=""><span class="" style="float: none; display: inline !important;">Internet Research Laboratory</span><br class=""><span class="" style="float: none; display: inline !important;">Computer Science Department</span><br class=""><span class="" style="float: none; display: inline !important;">UCLA</span></div><div class=""><br class=""></div></div></div></div><div><blockquote type="cite" class=""><div class="">On Jul 9, 2017, at 4:03 PM, Rakesh Ranjan Jha <<a href="mailto:rakeshranjan.jha@gmail.com" class="">rakeshranjan.jha@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi Spyridon,<div class=""><br class=""></div><div class="">Thanks for answering. Let me clarify my statements:</div><div class=""><br class=""></div><div class="">m_forwarder currently in Strategy base class, Strategy.cpp is a private member and hence can't be accessed from derived class.</div><div class=""><div class=""><span style="background-color:rgb(217,210,233)" class="">class Strategy : public enable_shared_from_this<Strategy>, noncopyable</span></div><div class=""><span style="background-color:rgb(217,210,233)" class="">{</span></div></div><div class=""><span style="background-color:rgb(217,210,233)" class="">...</span></div><div class=""><div class=""><span style="background-color:rgb(217,210,233)" class="">private:</span></div><div class=""><span style="background-color:rgb(217,210,233)" class="">  Name m_name;</span></div><div class=""><span style="background-color:rgb(217,210,233)" class=""><br class=""></span></div><div class=""><span style="background-color:rgb(217,210,233)" class="">  /** \brief reference to the forwarder</span></div><div class=""><span style="background-color:rgb(217,210,233)" class="">   *</span></div><div class=""><span style="background-color:rgb(217,210,233)" class="">   *  Triggers can access forwarder indirectly via actions.</span></div><div class=""><span style="background-color:rgb(217,210,233)" class="">   */</span></div><div class=""><span style="background-color:rgb(217,210,233)" class="">  Forwarder& m_forwarder;</span></div></div><div class=""><span style="background-color:rgb(217,210,233)" class="">...</span></div><div class=""><span style="background-color:rgb(217,210,233)" class="">}</span></div><div class=""><br class=""></div><div class="">Also currently forwarder class has only Strategy base class as friend.</div><div class=""><br class=""></div><div class=""><div class=""><span style="background-color:rgb(217,210,233)" class="">class Forwarder</span></div><div class=""><span style="background-color:rgb(217,210,233)" class="">{</span></div><div class=""><span style="background-color:rgb(217,210,233)" class="">...</span></div><div class=""><span style="background-color:rgb(217,210,233)" class="">  // allow Strategy (base class) to enter pipelines<br class=""></span></div></div><div class=""><div class=""><span style="background-color:rgb(217,210,233)" class="">  friend class fw::Strategy;</span></div><div class=""><span style="background-color:rgb(217,210,233)" class="">};</span></div></div><div class=""><br class=""></div><div class="">So, as I mentioned earlier to work around these I made m_forwarder a protected member and also added my strategy class as friend to forwarder as well.</div><div class=""><br class=""></div><div class="">With these changes now I can access the pipeline as well as access private members of m_fowarder but then I see the error when trying to access the content store and send the fetched data in the outgoing pipeline. What I wasn't sure is that similar call in forwarder passes but fails in my strategy class</div><div class=""><br class=""></div><div class=""><div style="font-size:12.8px" class=""><span style="background-color:rgb(217,210,233)" class="">//fowarder.cpp - This passes</span></div><div style="font-size:12.8px" class=""><div class=""><span style="background-color:rgb(217,210,233)" class="">    if (m_csFromNdnSim == nullptr) {</span></div><div class=""><span style="background-color:rgb(217,210,233)" class="">      m_cs.find(interest,</span></div><div class=""><span style="background-color:rgb(217,210,233)" class="">                bind(&Forwarder::<wbr class="">onContentStoreHit, this, ref(inFace), pitEntry, _1, _2),</span></div><div class=""><span style="background-color:rgb(217,210,233)" class="">                bind(&Forwarder::<wbr class="">onContentStoreMiss, this, ref(inFace), pitEntry, _1));</span></div><div class=""><span style="background-color:rgb(217,210,233)" class="">    }</span></div></div><div style="font-size:12.8px" class=""><span style="background-color:rgb(217,210,233)" class=""><br class=""></span></div><div style="font-size:12.8px" class=""><span style="background-color:rgb(217,210,233)" class="">//myStrategy.cpp - This fails</span></div><div style="font-size:12.8px" class=""><span style="background-color:rgb(217,210,233)" class="">    if (m_forwarder.m_csFromNdnSim == nullptr) {</span></div><div style="font-size:12.8px" class=""><span style="background-color:rgb(217,210,233)" class="">        /* m_forwarder is a reference to forwarder */             </span></div><div style="font-size:12.8px" class=""><div class=""><span style="background-color:rgb(217,210,233)" class=""><span style="white-space:pre-wrap" class="">   </span>m_forwarder.m_cs.find(pe-><wbr class="">getInterest(),</span></div><div class=""><span style="background-color:rgb(217,210,233)" class="">                  bind(&Forwarder::<wbr class="">onContentStoreHit, &m_forwarder, ref(face), pe, _1, _2),</span></div><div class=""><span style="background-color:rgb(217,210,233)" class=""><span style="white-space:pre-wrap" class="">          </span>  bind(&Forwarder::<wbr class="">onContentStoreMiss, &m_forwarder, ref(face), pe, _1));</span></div><div class=""><span style="background-color:rgb(217,210,233)" class="">     }</span></div><div class=""><br class=""></div></div></div><div class=""><br class=""></div><div class="">Also if there is a better way to access the CS and outgoing pipeline from strategy please let me know.</div><div class=""><br class=""></div><div class="">Thanks again,</div><div class="">Rakesh</div><div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Sun, Jul 9, 2017 at 6:47 PM, Spyridon (Spyros) Mastorakis <span dir="ltr" class=""><<a href="mailto:mastorakis@cs.ucla.edu" target="_blank" class="">mastorakis@cs.ucla.edu</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">Hi Rakesh,<div class=""><br class=""></div><div class="">I would like to make 2 comments about your code:<br class=""><div class=""><br class=""></div><div class="">1) m_forwarder is already a reference to an object of type Forwarder, so you tried to get a reference out of a reference.</div><div class=""><br class=""></div><div class="">2) The m_cs attribute is declared as a private member of the Forwarder class.</div><div class=""><br class=""></div><div class="">Please let me know if you have any questions.</div><div class=""><br class=""></div><div class="">Thank you,</div><div class=""><br class=""><div class="">
<div class=""><div class=""><div class=""><span style="float:none;display:inline!important" class="">Spyridon (Spyros) Mastorakis</span><br class=""><span style="float:none;display:inline!important" class="">Personal Website: </span><a href="http://cs.ucla.edu/~mastorakis/" target="_blank" class="">http://cs.ucla.edu/~<wbr class="">mastorakis/</a><br class=""><span style="float:none;display:inline!important" class="">Internet Research Laboratory</span><br class=""><span style="float:none;display:inline!important" class="">Computer Science Department</span><br class=""><span style="float:none;display:inline!important" class="">UCLA</span></div></div></div>
</div><div class=""><div class="h5">
<br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jul 9, 2017, at 10:30 AM, Rakesh Ranjan Jha <<a href="mailto:rakeshranjan.jha@gmail.com" target="_blank" class="">rakeshranjan.jha@gmail.com</a>> wrote:</div><br class="m_-7058948722893962250Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi,<div class=""><br class=""></div><div class="">I'm trying to spontaneously inject a cached data (based on a previously unfulfilled interest present in PIT and so I have an interest handle to fetch data) from content store.</div><div class=""><br class=""></div><div class="">However, I'm facing some issues:</div><div class=""><br class=""></div><div class="">1) Derived strategy doesn't seem to have any handle to fowarder although base strategy has a handle and is friend to forwarder to access pipelines. </div><div class="">In order to workaround this I added my strategy also as a friend and gave it a reference to forwarder, similar to base strategy. Is there a better way to access pipeline from strategy?</div><div class=""><br class=""></div><div class="">2) To access data from CS and feed it to outgoing data pipeline, I follow similar mechanism as done on receiving valid interest from forwarder:</div><div class="">//fowarder.cpp</div><div class=""><div class="">    if (m_csFromNdnSim == nullptr) {</div><div class="">      m_cs.find(interest,</div><div class="">                bind(&Forwarder::<wbr class="">onContentStoreHit, this, ref(inFace), pitEntry, _1, _2),</div><div class="">                bind(&Forwarder::<wbr class="">onContentStoreMiss, this, ref(inFace), pitEntry, _1));</div><div class="">    }</div></div><div class=""><br class=""></div><div class="">//myStrategy.cpp</div><div class="">    if (m_forwarder.m_csFromNdnSim == nullptr) {</div><div class="">        /* m_forwarder is a reference to forwarder */             </div><div class=""><div class=""><span style="white-space:pre-wrap" class="">  </span>m_forwarder.m_cs.find(pe-><wbr class="">getInterest(),</div><div class="">                  bind(&Forwarder::<wbr class="">onContentStoreHit, &m_forwarder, ref(face), pe, _1, _2),</div><div class=""><span style="white-space:pre-wrap" class="">          </span>  bind(&Forwarder::<wbr class="">onContentStoreMiss, &m_forwarder, ref(face), pe, _1));</div><div class="">     }</div></div><div class=""><br class=""></div><div class="">However this fails compilation and I get error as below:</div><div class=""><br class=""></div><div class=""><div class=""><font color="#ff0000" class="">../src/ndnSIM/NFD/daemon/fw/<wbr class="">my_strategy.cpp: In member function ‘virtual void nfd::fw::MyStrategy::<wbr class="">beforeSatisfyInterest(std::<wbr class="">shared_ptr<nfd::pit::Entry>, const nfd::Face&, const ndn::Data&)’:</font></div><div class=""><font color="#ff0000" class="">../src/ndnSIM/NFD/daemon/fw/<wbr class="">my_strategy.cpp:243:75: error: no matching function for call to ‘nfd::cs::Cs::find(const ndn::Interest&, std::_Bind_helper<false, void (nfd::Forwarder::*)(const nfd::Face&, std::shared_ptr<nfd::pit::<wbr class="">Entry>, const ndn::Interest&, const ndn::Data&), nfd::Forwarder*, std::reference_wrapper<int>, std::shared_ptr<nfd::pit::<wbr class="">Entry>&, const std::_Placeholder<1>&, const std::_Placeholder<2>&>::type, std::_Bind_helper<false, void (nfd::Forwarder::*)(const nfd::Face&, std::shared_ptr<nfd::pit::<wbr class="">Entry>, const ndn::Interest&), nfd::Forwarder*, std::reference_wrapper<int>, std::shared_ptr<nfd::pit::<wbr class="">Entry>&, const std::_Placeholder<1>&>::type)’</font></div><div class=""><font color="#ff0000" class="">      bind(&Forwarder::<wbr class="">onContentStoreMiss, &m_forwarder, ref(face), pe, _1));</font></div><div class=""><font color="#ff0000" class="">                                                                           ^</font></div><div class=""><font color="#ff0000" class="">In file included from ../src/ndnSIM/NFD/daemon/fw/<wbr class="">forwarder.hpp:35:0,</font></div><div class=""><font color="#ff0000" class="">                 from ../src/ndnSIM/NFD/daemon/fw/<wbr class="">strategy.hpp:29,</font></div><div class=""><font color="#ff0000" class="">                 from ../src/ndnSIM/NFD/daemon/fw/<wbr class="">my_strategy.hpp:24,</font></div><div class=""><font color="#ff0000" class="">                 from ../src/ndnSIM/NFD/daemon/fw/<wbr class="">my_strategy.cpp:21:</font></div><div class=""><font color="#ff0000" class="">../src/ndnSIM/NFD/daemon/fw/..<wbr class="">/table/cs.hpp:88:3: note: candidate: void nfd::cs::Cs::find(const ndn::Interest&, const HitCallback&, const MissCallback&) const</font></div><div class=""><font color="#ff0000" class="">   find(const Interest& interest,</font></div><div class=""><font color="#ff0000" class="">   ^</font></div><div class=""><font color="#ff0000" class="">../src/ndnSIM/NFD/daemon/fw/..<wbr class="">/table/cs.hpp:88:3: note:   no known conversion for argument 2 from ‘std::_Bind_helper<false, void (nfd::Forwarder::*)(const nfd::Face&, std::shared_ptr<nfd::pit::<wbr class="">Entry>, const ndn::Interest&, const ndn::Data&), nfd::Forwarder*, std::reference_wrapper<int>, std::shared_ptr<nfd::pit::<wbr class="">Entry>&, const std::_Placeholder<1>&, const std::_Placeholder<2>&>::type {aka std::_Bind<std::_Mem_fn<void (nfd::Forwarder::*)(const nfd::Face&, std::shared_ptr<nfd::pit::<wbr class="">Entry>, const ndn::Interest&, const ndn::Data&)>(nfd::Forwarder*, std::reference_wrapper<int>, std::shared_ptr<nfd::pit::<wbr class="">Entry>, std::_Placeholder<1>, std::_Placeholder<2>)>}’ to ‘const HitCallback& {aka const std::function<void(const ndn::Interest&, const ndn::Data&)>&}’</font></div></div><div class=""><br class=""></div><div class="">Can somebody help me figure out why this fails when similar invocation from forwarder passes?</div><div class=""><br class=""></div><div class="">Thanks in advance,</div><div class="">Rakesh</div><div class=""><br class=""></div></div></div></blockquote></div><br class=""></div></div></div></div></div></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></body></html>