blob: 921e711ad35d3981ee66999e0cd1f9919597e2f6 [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_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
36 class Endorsement {
37 public:
38 std::string type;
39 std::string value;
40 std::string count;
41 };
42
43public:
44
45 EndorseInfo();
46
47 explicit
48 EndorseInfo(const Block& endorseWire);
49
50 const Block&
51 wireEncode() const;
52
53 void
54 wireDecode(const Block& endorseWire);
55
56 const std::vector<Endorsement>&
57 getEndorsements() const;
58
59 void
60 addEndorsement(const std::string& type, const std::string& value, const std::string& count);
61
62private:
63 template<bool T>
64 size_t
65 wireEncode(ndn::EncodingImpl<T>& block) const;
66
67private:
68 mutable Block m_wire;
69 std::vector<Endorsement> m_endorsements;
70};
71
72inline const std::vector<EndorseInfo::Endorsement>&
73EndorseInfo::getEndorsements() const
74{
75 return m_endorsements;
76}
77
78
79} // namespace chronochat
80
81#endif //CHRONOCHAT_ENDORSE_INFO_HPP