[ndnSIM] How to Distinguish ContentTypes and downcast to them

Muhammad Hosain Abdollahi Sabet mhasabet at gmail.com
Sun Oct 9 13:53:55 PDT 2016


Junxiao,

You mean encode a packet into a type (e.g. Link) then decode it, to be able
to do some process with it?

What if peeking into link service? Or it will be more difficult from
programming perspective?

Thanks,
Sabet

On 9 Oct 2016 8:21 pm, "Junxiao Shi" <shijunxiao at email.arizona.edu> wrote:
>
> 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/20161010/118e96c7/attachment.html>


More information about the ndnSIM mailing list