<div dir="ltr">Hi Sabet<div><br></div><div>When a Data instance is created during packet decoding, the instance is of Data type, not a subclass of Data. Thus, you cannot downcast it with static_cast.</div><div><br></div><div>If it's determined that the Data is a Link, you may construct a new Link instance and decode from the wire encoding:</div><div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font face="monospace, monospace">ndn::Link link(data.wireEncode());</font></div></blockquote></div><div><br></div><div>Similarly, you can:</div><div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font face="monospace, monospace">ndn::security::v1::Certificate cert(data);</font></div></blockquote></div><div>Certificate has a constructor from Data, which allows you to omit wireEncode().</div><div><br></div><div>ContentType=NACK refers to producer generated Nack, which has no particular structure. A producer generated Nack is just a regular Data.</div><div>This is completely unrelated to ndn::lp::Nack.</div><div><br></div><div>Yours, Junxiao<br><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Oct 9, 2016 at 7:36 AM, Muhammad Hosain Abdollahi Sabet <span dir="ltr"><<a href="mailto:mhasabet@gmail.com" target="_blank">mhasabet@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-family:tahoma,sans-serif">​Hello everyone,</div><div style="font-family:tahoma,sans-serif"> </div><div style="font-family:tahoma,sans-serif">My application recieves a Data packet. How can I downcast it to its Type? I mean, for example downcast a data packet to Key or Link or Nack based on getContentType of the packet. I know it is more of a c++ question, but again I haven't been able to do it yet in ndnSIM.</div><div style="font-family:tahoma,sans-serif"> </div><div style="font-family:tahoma,sans-serif">Thanks,</div><div style="font-family:tahoma,sans-serif">Sabet</div></div>
</blockquote></div><br></div></div></div>