blob: a265dd98fa3e98a2b37c4be8e1ab47a4d97277a2 [file] [log] [blame]
Qiuhan Ding0cfc1512015-02-17 17:44:11 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/*
Varun Patila24bd3e2020-11-24 10:08:33 +05303 * Copyright (c) 2020, Regents of the University of California
Qiuhan Ding0cfc1512015-02-17 17:44:11 -08004 *
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_INFO_HPP
11#define CHRONOCHAT_ENDORSE_INFO_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 EndorseInfo
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
Varun Patila24bd3e2020-11-24 10:08:33 +053036 class Endorsement
37 {
Qiuhan Ding0cfc1512015-02-17 17:44:11 -080038 public:
39 std::string type;
40 std::string value;
41 std::string count;
42 };
43
44public:
45
46 EndorseInfo();
47
48 explicit
49 EndorseInfo(const Block& endorseWire);
50
51 const Block&
52 wireEncode() const;
53
54 void
55 wireDecode(const Block& endorseWire);
56
57 const std::vector<Endorsement>&
58 getEndorsements() const;
59
60 void
61 addEndorsement(const std::string& type, const std::string& value, const std::string& count);
62
63private:
Varun Patil3d850902020-11-23 12:19:14 +053064 template<ndn::encoding::Tag T>
Qiuhan Ding0cfc1512015-02-17 17:44:11 -080065 size_t
66 wireEncode(ndn::EncodingImpl<T>& block) const;
67
68private:
69 mutable Block m_wire;
70 std::vector<Endorsement> m_endorsements;
71};
72
73inline const std::vector<EndorseInfo::Endorsement>&
74EndorseInfo::getEndorsements() const
75{
76 return m_endorsements;
77}
78
79
80} // namespace chronochat
81
Varun Patila24bd3e2020-11-24 10:08:33 +053082#endif // CHRONOCHAT_ENDORSE_INFO_HPP