blob: 0626bf1905d7317eac46e2dcd3c93f7885c17460 [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_CONFIG_HPP
11#define CHRONOCHAT_CONFIG_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#include <list>
19
20namespace chronochat {
21
22class Conf
23{
24
25public:
26
27 class Error : public std::runtime_error
28 {
29 public:
30 explicit
31 Error(const std::string& what)
32 : std::runtime_error(what)
33 {
34 }
35 };
36
37public:
38
39 Conf();
40
41 explicit
42 Conf(const Block& confWire);
43
44 const Block&
45 wireEncode() const;
46
47 void
48 wireDecode(const Block& confWire);
49
50 const Name&
51 getIdentity() const;
52
53 const std::string&
54 getNick() const;
55
56 void
57 setIdentity(const Name& identity);
58
59 void
60 setNick(const std::string& nick);
61
62private:
63 template<bool T>
64 size_t
65 wireEncode(ndn::EncodingImpl<T>& block) const;
66
67private:
68 mutable Block m_wire;
69 Name m_identity;
70 std::string m_nick;
71};
72
73inline const Name&
74Conf::getIdentity() const
75{
76 return m_identity;
77}
78
79inline const std::string&
80Conf::getNick() const
81{
82 return m_nick;
83}
84
85} // namespace chronochat
86
87#endif //CHRONOCHAT_CONF_HPP