Qiuhan Ding | 0cfc151 | 2015-02-17 17:44:11 -0800 | [diff] [blame] | 1 | /* -*- 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 | |
| 20 | namespace chronochat { |
| 21 | |
| 22 | class Conf |
| 23 | { |
| 24 | |
| 25 | public: |
| 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 | |
| 37 | public: |
| 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 | |
| 62 | private: |
Varun Patil | 3d85090 | 2020-11-23 12:19:14 +0530 | [diff] [blame^] | 63 | template<ndn::encoding::Tag T> |
Qiuhan Ding | 0cfc151 | 2015-02-17 17:44:11 -0800 | [diff] [blame] | 64 | size_t |
| 65 | wireEncode(ndn::EncodingImpl<T>& block) const; |
| 66 | |
| 67 | private: |
| 68 | mutable Block m_wire; |
| 69 | Name m_identity; |
| 70 | std::string m_nick; |
| 71 | }; |
| 72 | |
| 73 | inline const Name& |
| 74 | Conf::getIdentity() const |
| 75 | { |
| 76 | return m_identity; |
| 77 | } |
| 78 | |
| 79 | inline const std::string& |
| 80 | Conf::getNick() const |
| 81 | { |
| 82 | return m_nick; |
| 83 | } |
| 84 | |
| 85 | } // namespace chronochat |
| 86 | |
| 87 | #endif //CHRONOCHAT_CONF_HPP |