[ndnSIM] How to Distinguish ContentTypes and downcast to them
Junxiao Shi
shijunxiao at email.arizona.edu
Sun Oct 9 09:50:24 PDT 2016
Hi Sabet
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.
If it's determined that the Data is a Link, you may construct a new Link
instance and decode from the wire encoding:
ndn::Link link(data.wireEncode());
Similarly, you can:
ndn::security::v1::Certificate cert(data);
Certificate has a constructor from Data, which allows you to omit
wireEncode().
ContentType=NACK refers to producer generated Nack, which has no particular
structure. A producer generated Nack is just a regular Data.
This is completely unrelated to ndn::lp::Nack.
Yours, Junxiao
On Sun, Oct 9, 2016 at 7:36 AM, Muhammad Hosain Abdollahi Sabet <
mhasabet at gmail.com> wrote:
> Hello everyone,
>
> 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.
>
> Thanks,
> Sabet
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20161009/5816565a/attachment.html>
More information about the ndnSIM
mailing list