<div dir="ltr">Thanks a lot Spyros!<div><br></div><div>Hi Junxiao,</div><div>Will be very grateful for your input here.</div><div><br></div><div>Thanks,</div><div>Rakesh</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 11, 2017 at 10:52 PM, Spyridon (Spyros) Mastorakis <span dir="ltr"><<a href="mailto:mastorakis@cs.ucla.edu" target="_blank">mastorakis@cs.ucla.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi Rakesh,<div><br></div><div>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><br></div><div>Thanks,</div><div><span class=""><br><div>
<div><div><div><span style="float:none;display:inline!important">Spyridon (Spyros) Mastorakis</span><br><span style="float:none;display:inline!important">Personal Website: </span><a href="http://cs.ucla.edu/~mastorakis/" target="_blank">http://cs.ucla.edu/~<wbr>mastorakis/</a><br><span style="float:none;display:inline!important">Internet Research Laboratory</span><br><span style="float:none;display:inline!important">Computer Science Department</span><br><span style="float:none;display:inline!important">UCLA</span></div><div><br></div></div></div></div></span><div><div class="h5"><div><blockquote type="cite"><div>On Jul 9, 2017, at 4:03 PM, Rakesh Ranjan Jha <<a href="mailto:rakeshranjan.jha@gmail.com" target="_blank">rakeshranjan.jha@gmail.com</a>> wrote:</div><br class="m_591456934724838421Apple-interchange-newline"><div><div dir="ltr">Hi Spyridon,<div><br></div><div>Thanks for answering. Let me clarify my statements:</div><div><br></div><div>m_forwarder currently in Strategy base class, Strategy.cpp is a private member and hence can't be accessed from derived class.</div><div><div><span style="background-color:rgb(217,210,233)">class Strategy : public enable_shared_from_this<<wbr>Strategy>, noncopyable</span></div><div><span style="background-color:rgb(217,210,233)">{</span></div></div><div><span style="background-color:rgb(217,210,233)">...</span></div><div><div><span style="background-color:rgb(217,210,233)">private:</span></div><div><span style="background-color:rgb(217,210,233)">  Name m_name;</span></div><div><span style="background-color:rgb(217,210,233)"><br></span></div><div><span style="background-color:rgb(217,210,233)">  /** \brief reference to the forwarder</span></div><div><span style="background-color:rgb(217,210,233)">   *</span></div><div><span style="background-color:rgb(217,210,233)">   *  Triggers can access forwarder indirectly via actions.</span></div><div><span style="background-color:rgb(217,210,233)">   */</span></div><div><span style="background-color:rgb(217,210,233)">  Forwarder& m_forwarder;</span></div></div><div><span style="background-color:rgb(217,210,233)">...</span></div><div><span style="background-color:rgb(217,210,233)">}</span></div><div><br></div><div>Also currently forwarder class has only Strategy base class as friend.</div><div><br></div><div><div><span style="background-color:rgb(217,210,233)">class Forwarder</span></div><div><span style="background-color:rgb(217,210,233)">{</span></div><div><span style="background-color:rgb(217,210,233)">...</span></div><div><span style="background-color:rgb(217,210,233)">  // allow Strategy (base class) to enter pipelines<br></span></div></div><div><div><span style="background-color:rgb(217,210,233)">  friend class fw::Strategy;</span></div><div><span style="background-color:rgb(217,210,233)">};</span></div></div><div><br></div><div>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><br></div><div>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><br></div><div><div style="font-size:12.8px"><span style="background-color:rgb(217,210,233)">//fowarder.cpp - This passes</span></div><div style="font-size:12.8px"><div><span style="background-color:rgb(217,210,233)">    if (m_csFromNdnSim == nullptr) {</span></div><div><span style="background-color:rgb(217,210,233)">      m_cs.find(interest,</span></div><div><span style="background-color:rgb(217,210,233)">                bind(&Forwarder::onContentStor<wbr>eHit, this, ref(inFace), pitEntry, _1, _2),</span></div><div><span style="background-color:rgb(217,210,233)">                bind(&Forwarder::onContentStor<wbr>eMiss, this, ref(inFace), pitEntry, _1));</span></div><div><span style="background-color:rgb(217,210,233)">    }</span></div></div><div style="font-size:12.8px"><span style="background-color:rgb(217,210,233)"><br></span></div><div style="font-size:12.8px"><span style="background-color:rgb(217,210,233)">//myStrategy.cpp - This fails</span></div><div style="font-size:12.8px"><span style="background-color:rgb(217,210,233)">    if (m_forwarder.m_csFromNdnSim == nullptr) {</span></div><div style="font-size:12.8px"><span style="background-color:rgb(217,210,233)">        /* m_forwarder is a reference to forwarder */             </span></div><div style="font-size:12.8px"><div><span style="background-color:rgb(217,210,233)"><span style="white-space:pre-wrap">      </span>m_forwarder.m_cs.find(pe->getI<wbr>nterest(),</span></div><div><span style="background-color:rgb(217,210,233)">                  bind(&Forwarder::onContentStor<wbr>eHit, &m_forwarder, ref(face), pe, _1, _2),</span></div><div><span style="background-color:rgb(217,210,233)"><span style="white-space:pre-wrap">           </span>  bind(&Forwarder::onContentSt<wbr>oreMiss, &m_forwarder, ref(face), pe, _1));</span></div><div><span style="background-color:rgb(217,210,233)">     }</span></div><div><br></div></div></div><div><br></div><div>Also if there is a better way to access the CS and outgoing pipeline from strategy please let me know.</div><div><br></div><div>Thanks again,</div><div>Rakesh</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jul 9, 2017 at 6:47 PM, Spyridon (Spyros) Mastorakis <span dir="ltr"><<a href="mailto:mastorakis@cs.ucla.edu" target="_blank">mastorakis@cs.ucla.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi Rakesh,<div><br></div><div>I would like to make 2 comments about your code:<br><div><br></div><div>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><br></div><div>2) The m_cs attribute is declared as a private member of the Forwarder class.</div><div><br></div><div>Please let me know if you have any questions.</div><div><br></div><div>Thank you,</div><div><br><div>
<div><div><div><span style="float:none;display:inline!important">Spyridon (Spyros) Mastorakis</span><br><span style="float:none;display:inline!important">Personal Website: </span><a href="http://cs.ucla.edu/~mastorakis/" target="_blank">http://cs.ucla.edu/~m<wbr>astorakis/</a><br><span style="float:none;display:inline!important">Internet Research Laboratory</span><br><span style="float:none;display:inline!important">Computer Science Department</span><br><span style="float:none;display:inline!important">UCLA</span></div></div></div>
</div><div><div class="m_591456934724838421h5">
<br><div><blockquote type="cite"><div>On Jul 9, 2017, at 10:30 AM, Rakesh Ranjan Jha <<a href="mailto:rakeshranjan.jha@gmail.com" target="_blank">rakeshranjan.jha@gmail.com</a>> wrote:</div><br class="m_591456934724838421m_-7058948722893962250Apple-interchange-newline"><div><div dir="ltr">Hi,<div><br></div><div>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><br></div><div>However, I'm facing some issues:</div><div><br></div><div>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>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><br></div><div>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>//fowarder.cpp</div><div><div>    if (m_csFromNdnSim == nullptr) {</div><div>      m_cs.find(interest,</div><div>                bind(&Forwarder::onContentStor<wbr>eHit, this, ref(inFace), pitEntry, _1, _2),</div><div>                bind(&Forwarder::onContentStor<wbr>eMiss, this, ref(inFace), pitEntry, _1));</div><div>    }</div></div><div><br></div><div>//myStrategy.cpp</div><div>    if (m_forwarder.m_csFromNdnSim == nullptr) {</div><div>        /* m_forwarder is a reference to forwarder */             </div><div><div><span style="white-space:pre-wrap">     </span>m_forwarder.m_cs.find(pe->getI<wbr>nterest(),</div><div>                  bind(&Forwarder::onContentStor<wbr>eHit, &m_forwarder, ref(face), pe, _1, _2),</div><div><span style="white-space:pre-wrap">             </span>  bind(&Forwarder::onContentSto<wbr>reMiss, &m_forwarder, ref(face), pe, _1));</div><div>     }</div></div><div><br></div><div>However this fails compilation and I get error as below:</div><div><br></div><div><div><font color="#ff0000">../src/ndnSIM/NFD/daemon/fw/my<wbr>_strategy.cpp: In member function ‘virtual void nfd::fw::MyStrategy::beforeSat<wbr>isfyInterest(std::shared_ptr<<wbr>nfd::pit::Entry>, const nfd::Face&, const ndn::Data&)’:</font></div><div><font color="#ff0000">../src/ndnSIM/NFD/daemon/fw/my<wbr>_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::Entr<wbr>y>, const ndn::Interest&, const ndn::Data&), nfd::Forwarder*, std::reference_wrapper<int>, std::shared_ptr<nfd::pit::Entr<wbr>y>&, const std::_Placeholder<1>&, const std::_Placeholder<2>&>::type, std::_Bind_helper<false, void (nfd::Forwarder::*)(const nfd::Face&, std::shared_ptr<nfd::pit::Entr<wbr>y>, const ndn::Interest&), nfd::Forwarder*, std::reference_wrapper<int>, std::shared_ptr<nfd::pit::Entr<wbr>y>&, const std::_Placeholder<1>&>::type)’</font></div><div><font color="#ff0000">      bind(&Forwarder::onContentStor<wbr>eMiss, &m_forwarder, ref(face), pe, _1));</font></div><div><font color="#ff0000">                                                                           ^</font></div><div><font color="#ff0000">In file included from ../src/ndnSIM/NFD/daemon/fw/fo<wbr>rwarder.hpp:35:0,</font></div><div><font color="#ff0000">                 from ../src/ndnSIM/NFD/daemon/fw/st<wbr>rategy.hpp:29,</font></div><div><font color="#ff0000">                 from ../src/ndnSIM/NFD/daemon/fw/my<wbr>_strategy.hpp:24,</font></div><div><font color="#ff0000">                 from ../src/ndnSIM/NFD/daemon/fw/my<wbr>_strategy.cpp:21:</font></div><div><font color="#ff0000">../src/ndnSIM/NFD/daemon/fw/..<wbr>/table/cs.hpp:88:3: note: candidate: void nfd::cs::Cs::find(const ndn::Interest&, const HitCallback&, const MissCallback&) const</font></div><div><font color="#ff0000">   find(const Interest& interest,</font></div><div><font color="#ff0000">   ^</font></div><div><font color="#ff0000">../src/ndnSIM/NFD/daemon/fw/..<wbr>/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::Entr<wbr>y>, const ndn::Interest&, const ndn::Data&), nfd::Forwarder*, std::reference_wrapper<int>, std::shared_ptr<nfd::pit::Entr<wbr>y>&, 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::Entr<wbr>y>, const ndn::Interest&, const ndn::Data&)>(nfd::Forwarder*, std::reference_wrapper<int>, std::shared_ptr<nfd::pit::Entr<wbr>y>, std::_Placeholder<1>, std::_Placeholder<2>)>}’ to ‘const HitCallback& {aka const std::function<void(const ndn::Interest&, const ndn::Data&)>&}’</font></div></div><div><br></div><div>Can somebody help me figure out why this fails when similar invocation from forwarder passes?</div><div><br></div><div>Thanks in advance,</div><div>Rakesh</div><div><br></div></div></div></blockquote></div><br></div></div></div></div></div></blockquote></div><br></div>
</div></blockquote></div><br></div></div></div></div></blockquote></div><br></div>