Jeff Thompson | 25b4e61 | 2013-10-10 16:03:24 -0700 | [diff] [blame] | 1 | /** |
| 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 |
| 13 | extern "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 | */ |
| 19 | struct 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 | */ |
| 29 | static 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 |