blob: c8bd11e9662f40d01f89ee6b4ecd2082805d0c6c [file] [log] [blame]
Qiuhan Ding0cfc1512015-02-17 17:44:11 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2013, Regents of the University of California
4 *
5 * BSD license, See the LICENSE file for more information
6 *
7 * Author: Qiuhan Ding <qiuhanding@cs.ucla.edu>
8 */
9
10#ifndef CHRONOCHAT_ENDORSE_EXTENSION_HPP
11#define CHRONOCHAT_ENDORSE_EXTENSION_HPP
12
13#include "common.hpp"
14#include "tlv.hpp"
15#include <ndn-cxx/util/concepts.hpp>
16#include <ndn-cxx/encoding/block.hpp>
17#include <ndn-cxx/encoding/encoding-buffer.hpp>
18#include <list>
19
20namespace chronochat {
21
22class EndorseExtension
23{
24
25public:
26
27 class Error : public std::runtime_error
28 {
29 public:
30 explicit
31 Error(const std::string& what)
32 : std::runtime_error(what)
33 {
34 }
35 };
36
37public:
38
39 EndorseExtension();
40
41 explicit
42 EndorseExtension(const Block& endorseWire);
43
44 const Block&
45 wireEncode() const;
46
47 void
48 wireDecode(const Block& endorseWire);
49
50 const std::list<std::string>&
51 getEntries() const;
52
53 void
54 addEntry(const std::string& entry);
55
56 void
57 removeEntry(const std::string& entry);
58
59private:
Varun Patil3d850902020-11-23 12:19:14 +053060 template<ndn::encoding::Tag T>
Qiuhan Ding0cfc1512015-02-17 17:44:11 -080061 size_t
62 wireEncode(ndn::EncodingImpl<T>& block) const;
63
64private:
65 mutable Block m_wire;
66 std::list<std::string> m_entries;
67};
68
69inline const std::list<std::string>&
70EndorseExtension::getEntries() const
71{
72 return m_entries;
73}
74
75
76} // namespace chronochat
77
78#endif //CHRONOCHAT_ENDORSE_EXTENSION_HPP