Qiuhan Ding | 0cfc151 | 2015-02-17 17:44:11 -0800 | [diff] [blame] | 1 | /* -*- 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 | |
| 20 | namespace chronochat { |
| 21 | |
| 22 | class EndorseExtension |
| 23 | { |
| 24 | |
| 25 | public: |
| 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 | |
| 37 | public: |
| 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 | |
| 59 | private: |
Varun Patil | 3d85090 | 2020-11-23 12:19:14 +0530 | [diff] [blame^] | 60 | template<ndn::encoding::Tag T> |
Qiuhan Ding | 0cfc151 | 2015-02-17 17:44:11 -0800 | [diff] [blame] | 61 | size_t |
| 62 | wireEncode(ndn::EncodingImpl<T>& block) const; |
| 63 | |
| 64 | private: |
| 65 | mutable Block m_wire; |
| 66 | std::list<std::string> m_entries; |
| 67 | }; |
| 68 | |
| 69 | inline const std::list<std::string>& |
| 70 | EndorseExtension::getEntries() const |
| 71 | { |
| 72 | return m_entries; |
| 73 | } |
| 74 | |
| 75 | |
| 76 | } // namespace chronochat |
| 77 | |
| 78 | #endif //CHRONOCHAT_ENDORSE_EXTENSION_HPP |