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_COLLECTION_HPP |
| 11 | #define CHRONOCHAT_ENDORSE_COLLECTION_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 | |
| 19 | namespace chronochat { |
| 20 | |
| 21 | class EndorseCollection |
| 22 | { |
| 23 | |
| 24 | public: |
| 25 | |
| 26 | class Error : public std::runtime_error |
| 27 | { |
| 28 | public: |
| 29 | explicit |
| 30 | Error(const std::string& what) |
| 31 | : std::runtime_error(what) |
| 32 | { |
| 33 | } |
| 34 | }; |
| 35 | |
| 36 | class CollectionEntry |
| 37 | { |
| 38 | public: |
| 39 | Name certName; |
| 40 | std::string hash; |
| 41 | }; |
| 42 | |
| 43 | public: |
| 44 | |
| 45 | EndorseCollection(); |
| 46 | |
| 47 | explicit |
| 48 | EndorseCollection(const Block& endorseWire); |
| 49 | |
| 50 | const Block& |
| 51 | wireEncode() const; |
| 52 | |
| 53 | void |
| 54 | wireDecode(const Block& endorseWire); |
| 55 | |
| 56 | const std::vector<CollectionEntry>& |
| 57 | getCollectionEntries() const; |
| 58 | |
| 59 | void |
| 60 | addCollectionEntry(const Name& certName, const std::string& hash); |
| 61 | |
| 62 | private: |
Varun Patil | 3d85090 | 2020-11-23 12:19:14 +0530 | [diff] [blame^] | 63 | template<ndn::encoding::Tag T> |
Qiuhan Ding | 0cfc151 | 2015-02-17 17:44:11 -0800 | [diff] [blame] | 64 | size_t |
| 65 | wireEncode(ndn::EncodingImpl<T>& block) const; |
| 66 | |
| 67 | private: |
| 68 | mutable Block m_wire; |
| 69 | std::vector<CollectionEntry> m_entries; |
| 70 | }; |
| 71 | |
| 72 | inline const std::vector<EndorseCollection::CollectionEntry>& |
| 73 | EndorseCollection::getCollectionEntries() const |
| 74 | { |
| 75 | return m_entries; |
| 76 | } |
| 77 | |
| 78 | } // namespace chronochat |
| 79 | |
| 80 | #endif //CHRONOCHAT_ENDORSE_COLLECTION_HPP |