blob: f2a86ff9eb8c8988ab9a9f394b48c97bdd387e04 [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 Thompson8b173cc2013-08-21 17:54:12 -070031 virtual void onReceivedElement(const unsigned char *element, unsigned int elementLength) = 0;
Jeff Thompson482fbd52013-07-15 16:45:29 -070032
33private:
34 /**
35 * Call the virtual method onReceivedElement. This is used to initialize the base ndn_ElementListener struct.
36 * @param self
37 * @param element
38 * @param elementLength
39 */
40 static void staticOnReceivedElement(struct ndn_ElementListener *self, unsigned char *element, unsigned int elementLength);
41};
42
43}
44
45#endif