blob: af88a85003eb5e6065eeb30e0b6f98c595252139 [file] [log] [blame]
Jeff Thompson25b4e612013-10-10 16:03:24 -07001/**
2 * Copyright (C) 2013 Regents of the University of California.
3 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
4 * See COPYING for copyright and distribution information.
5 */
6
7#ifndef NDN_ELEMENT_LISTENER_H
8#define NDN_ELEMENT_LISTENER_H
9
10#include "../common.h"
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
16/** An ndn_ElementListener struct holds a function pointer onReceivedElement. You can extend this struct with data that
17 * will be passed to onReceivedElement.
18 */
19struct ndn_ElementListener {
20 void (*onReceivedElement)(struct ndn_ElementListener *self, uint8_t *element, size_t elementLength); /**< see ndn_ElementListener_initialize */
21};
22
23/**
24 * Initialize an ndn_ElementListener struct to use the onReceivedElement function pointer.
25 * @param self pointer to the ndn_ElementListener struct
26 * @param onReceivedElement pointer to a function which is called when an entire binary XML element is received.
27 * self is the pointer to this ndn_ElementListener struct. See ndn_BinaryXmlElementReader_onReceivedData.
28 */
29static inline void ndn_ElementListener_initialize
30 (struct ndn_ElementListener *self, void (*onReceivedElement)(struct ndn_ElementListener *self, uint8_t *element, size_t elementLength))
31{
32 self->onReceivedElement = onReceivedElement;
33}
34
35#ifdef __cplusplus
36}
37#endif
38
39#endif