blob: 5aed8a0ac210cab7ee510b96f80cfbdddab06036 [file] [log] [blame]
Jeff Thompson482fbd52013-07-15 16:45:29 -07001/**
Jeff Thompson7687dc02013-09-13 11:54:07 -07002 * Copyright (C) 2013 Regents of the University of California.
3 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
Jeff Thompson482fbd52013-07-15 16:45:29 -07004 * See COPYING for copyright and distribution information.
5 */
6
7#ifndef NDN_BINARYXMLELEMENTREADER_HPP
Jeff Thompson2d27e2f2013-08-09 12:55:00 -07008#define NDN_BINARYXMLELEMENTREADER_HPP
Jeff Thompson482fbd52013-07-15 16:45:29 -07009
Jeff Thompson53412192013-08-06 13:35:50 -070010#include "../c/encoding/binary-xml-element-reader.h"
Jeff Thompson482fbd52013-07-15 16:45:29 -070011
12namespace ndn {
13
14/**
15 * An ElementListener extends an ndn_ElementListener struct to proved an abstract virtual onReceivedElement function which wraps
16 * the onReceivedElement used by the ndn_ElementListener struct. You must extend this class to override onReceivedElement.
17 */
Jeff Thompson48abd922013-07-16 16:08:26 -070018class ElementListener : public ndn_ElementListener {
Jeff Thompson482fbd52013-07-15 16:45:29 -070019public:
20 ElementListener()
21 {
Jeff Thompsond1427fb2013-08-29 17:20:32 -070022 ndn_ElementListener_initialize(this, staticOnReceivedElement);
Jeff Thompson482fbd52013-07-15 16:45:29 -070023 }
24
25 /**
26 * This is called when an entire binary XML element is received. You must extend this class to override this method.
27 * @param element pointer to the binary XML element. This buffer is only valid during this call. If you need the data
28 * later, you must copy.
29 * @param elementLength length of element
30 */
Jeff Thompson0050abe2013-09-17 12:50:25 -070031 virtual void
Jeff Thompson10ad12a2013-09-24 16:19:11 -070032 onReceivedElement(const uint8_t *element, unsigned int elementLength) = 0;
Jeff Thompson482fbd52013-07-15 16:45:29 -070033
34private:
35 /**
36 * Call the virtual method onReceivedElement. This is used to initialize the base ndn_ElementListener struct.
37 * @param self
38 * @param element
39 * @param elementLength
40 */
Jeff Thompson0050abe2013-09-17 12:50:25 -070041 static void
Jeff Thompson10ad12a2013-09-24 16:19:11 -070042 staticOnReceivedElement(struct ndn_ElementListener *self, uint8_t *element, unsigned int elementLength);
Jeff Thompson482fbd52013-07-15 16:45:29 -070043};
44
45}
46
47#endif