blob: dd16bc360841de910f02969be44c936e84fb6d61 [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_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
19namespace chronochat {
20
21class EndorseCollection
22{
23
24public:
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
43public:
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
62private:
Varun Patil3d850902020-11-23 12:19:14 +053063 template<ndn::encoding::Tag T>
Qiuhan Ding0cfc1512015-02-17 17:44:11 -080064 size_t
65 wireEncode(ndn::EncodingImpl<T>& block) const;
66
67private:
68 mutable Block m_wire;
69 std::vector<CollectionEntry> m_entries;
70};
71
72inline const std::vector<EndorseCollection::CollectionEntry>&
73EndorseCollection::getCollectionEntries() const
74{
75 return m_entries;
76}
77
78} // namespace chronochat
79
80#endif //CHRONOCHAT_ENDORSE_COLLECTION_HPP