/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
/*
 * Copyright (c) 2020, Regents of the University of California
 *
 * BSD license, See the LICENSE file for more information
 *
 * Author: Qiuhan Ding <qiuhanding@cs.ucla.edu>
 */

#ifndef CHRONOCHAT_ENDORSE_INFO_HPP
#define CHRONOCHAT_ENDORSE_INFO_HPP

#include "common.hpp"
#include "tlv.hpp"
#include <ndn-cxx/util/concepts.hpp>
#include <ndn-cxx/encoding/block.hpp>
#include <ndn-cxx/encoding/encoding-buffer.hpp>

namespace chronochat {

class EndorseInfo
{

public:

  class Error : public std::runtime_error
  {
  public:
    explicit
    Error(const std::string& what)
      : std::runtime_error(what)
    {
    }
  };

  class Endorsement
  {
  public:
    std::string type;
    std::string value;
    std::string count;
  };

public:

  EndorseInfo();

  explicit
  EndorseInfo(const Block& endorseWire);

  const Block&
  wireEncode() const;

  void
  wireDecode(const Block& endorseWire);

  const std::vector<Endorsement>&
  getEndorsements() const;

  void
  addEndorsement(const std::string& type, const std::string& value, const std::string& count);

private:
  template<ndn::encoding::Tag T>
  size_t
  wireEncode(ndn::EncodingImpl<T>& block) const;

private:
  mutable Block m_wire;
  std::vector<Endorsement> m_endorsements;
};

inline const std::vector<EndorseInfo::Endorsement>&
EndorseInfo::getEndorsements() const
{
  return m_endorsements;
}


} // namespace chronochat

#endif // CHRONOCHAT_ENDORSE_INFO_HPP
