blob: 8df9f62a12aa706b12aab49611ff2af7f61b6f13 [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
Varun Patila24bd3e2020-11-24 10:08:33 +053010#ifndef CHRONOCHAT_CONF_HPP
11#define CHRONOCHAT_CONF_HPP
Qiuhan Ding0cfc1512015-02-17 17:44:11 -080012
13#include "common.hpp"
14#include "tlv.hpp"
Qiuhan Ding0cfc1512015-02-17 17:44:11 -080015
16namespace chronochat {
17
18class Conf
19{
20
21public:
22
23 class Error : public std::runtime_error
24 {
25 public:
26 explicit
27 Error(const std::string& what)
28 : std::runtime_error(what)
29 {
30 }
31 };
32
33public:
34
35 Conf();
36
37 explicit
38 Conf(const Block& confWire);
39
40 const Block&
41 wireEncode() const;
42
43 void
44 wireDecode(const Block& confWire);
45
46 const Name&
47 getIdentity() const;
48
49 const std::string&
50 getNick() const;
51
52 void
53 setIdentity(const Name& identity);
54
55 void
56 setNick(const std::string& nick);
57
58private:
Varun Patil3d850902020-11-23 12:19:14 +053059 template<ndn::encoding::Tag T>
Qiuhan Ding0cfc1512015-02-17 17:44:11 -080060 size_t
61 wireEncode(ndn::EncodingImpl<T>& block) const;
62
63private:
64 mutable Block m_wire;
65 Name m_identity;
66 std::string m_nick;
67};
68
69inline const Name&
70Conf::getIdentity() const
71{
72 return m_identity;
73}
74
75inline const std::string&
76Conf::getNick() const
77{
78 return m_nick;
79}
80
81} // namespace chronochat
82
Varun Patila24bd3e2020-11-24 10:08:33 +053083#endif // CHRONOCHAT_CONF_HPP