[Ndn-lib] Introducing NDN-CPP Lite

Thompson, Jeff jefft0 at remap.ucla.edu
Fri Apr 3 15:59:02 PDT 2015


Hello all,

New code has been added to NDN-CPP in GitHub for NDN-CPP Lite, a light-weight C++ layer over the C language core in NDN-CPP.

The main C++ API for NDN-CPP uses the Standard Library classes like std::vector and shared_ptr to automatically manage memory in objects. For data packet encoding, decoding and network transport, the C++ API calls an inner core written in pure C which does not make any assumptions about memory management or support libraries.

Some low-power platforms like an Arduino microcontroller don't support the C++ Standard Library or run-time info for exceptions. To support such platforms, the NDN-CPP Lite API was developed which, like the C core, does not make assumptions about memory management or support libraries. While functionally equivalent to the C core, the NDN-CPP Lite takes advantage of C++ syntax to simplify the API. For example, the following C code initializes a MetaInfo struct:

struct ndn_MetaInfo metaInfo;
ndn_MetaInfo_initialize(&metaInfo);


The following equivalent NDN-CPP Lite code initializes a MetaInfoLite object:

MetaInfoLite metaInfo;


The MetaInfoLite constructor internally calls the same ndn_MetaInfo_initialize function, but C++ syntax, method overloading and namespace support makes the NDN-CPP Lite code cleaner and less error-prone.

The file examples/arduino/analog-reading/analog-reading.ino<https://github.com/named-data/ndn-cpp/blob/master/examples/arduino/analog-reading/analog-reading.ino> uses NDN-CPP Lite for an Arduino application which registers a prefix, receives an interest over TCP and returns a signed (with HMAC) data packet holding a measurement value. The compiled application is about 28 kilobytes as required by the small microcontroller program space.

For more explanation and sample code, see README-NDN-CPP-Lite.md<https://github.com/named-data/ndn-cpp/blob/master/README-NDN-CPP-Lite.md>. Currently, the NDN-CPP Lite documentation is in the class and method doc comments in include/ndn-cpp/lite<https://github.com/named-data/ndn-cpp/tree/master/include/ndn-cpp/lite>.

Thank you,

- Jeff T
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndn-lib/attachments/20150403/8c375a0e/attachment.html>


More information about the Ndn-lib mailing list