[ndnSIM] GetTypeId() for user defined object.

Alex Afanasyev alexander.afanasyev at ucla.edu
Fri Apr 24 20:26:48 PDT 2015

> On Apr 24, 2015, at 12:21 AM, Anil Jangam <anilj.mailing at gmail.com> wrote:
> Hi,
> In my ndn application, which is a composition of other user defined objects, I am trying to write "TypeId GetTypeId(void)" function. I checked some existing examples, and found that most of them are composition of NS and basic data type objects (e.g. Name, Time, uint32_t etc).
> I don't quite understand in my case how do I write the GetTypeId function and how to use the AddAttribute() for user defined objects. For instance for object of type Name, there is MakeNameAccessor() and MakeNameChecker() functions, and these are used in AddAttribute.
> Do I have to define these Accessor and Checker functions for my user defined objects?

Hi Anil,

For your custom objects, you don’t need to explicitly define the accessor, but you need to make sure to add a few things for checker and accessor to be automatically created:

1. Implement std::ostream& operator<<(std::ostream&, const YourCustomType&);
2. Implement std::istream& operator>>(std::istream& YourCustomType&);
3. You need to add the following macro in the header file of your type:


4. And this macro to .cpp file:


* * *

After these steps, you should be able to use your type inside GetTypeId() method.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 841 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20150424/96389ae7/attachment.bin>

More information about the ndnSIM mailing list