Qiuhan Ding | 0cfc151 | 2015-02-17 17:44:11 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
Varun Patil | a24bd3e | 2020-11-24 10:08:33 +0530 | [diff] [blame^] | 3 | * Copyright (c) 2020, Regents of the University of California |
Qiuhan Ding | 0cfc151 | 2015-02-17 17:44:11 -0800 | [diff] [blame] | 4 | * |
| 5 | * BSD license, See the LICENSE file for more information |
| 6 | * |
| 7 | * Author: Qiuhan Ding <qiuhanding@cs.ucla.edu> |
| 8 | */ |
| 9 | |
Varun Patil | a24bd3e | 2020-11-24 10:08:33 +0530 | [diff] [blame^] | 10 | #ifndef CHRONOCHAT_CONF_HPP |
| 11 | #define CHRONOCHAT_CONF_HPP |
Qiuhan Ding | 0cfc151 | 2015-02-17 17:44:11 -0800 | [diff] [blame] | 12 | |
| 13 | #include "common.hpp" |
| 14 | #include "tlv.hpp" |
Qiuhan Ding | 0cfc151 | 2015-02-17 17:44:11 -0800 | [diff] [blame] | 15 | |
| 16 | namespace chronochat { |
| 17 | |
| 18 | class Conf |
| 19 | { |
| 20 | |
| 21 | public: |
| 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 | |
| 33 | public: |
| 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 | |
| 58 | private: |
Varun Patil | 3d85090 | 2020-11-23 12:19:14 +0530 | [diff] [blame] | 59 | template<ndn::encoding::Tag T> |
Qiuhan Ding | 0cfc151 | 2015-02-17 17:44:11 -0800 | [diff] [blame] | 60 | size_t |
| 61 | wireEncode(ndn::EncodingImpl<T>& block) const; |
| 62 | |
| 63 | private: |
| 64 | mutable Block m_wire; |
| 65 | Name m_identity; |
| 66 | std::string m_nick; |
| 67 | }; |
| 68 | |
| 69 | inline const Name& |
| 70 | Conf::getIdentity() const |
| 71 | { |
| 72 | return m_identity; |
| 73 | } |
| 74 | |
| 75 | inline const std::string& |
| 76 | Conf::getNick() const |
| 77 | { |
| 78 | return m_nick; |
| 79 | } |
| 80 | |
| 81 | } // namespace chronochat |
| 82 | |
Varun Patil | a24bd3e | 2020-11-24 10:08:33 +0530 | [diff] [blame^] | 83 | #endif // CHRONOCHAT_CONF_HPP |