Yingdi Yu | f4aaa8b | 2014-03-10 11:24:31 -0700 | [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 |
Yingdi Yu | f4aaa8b | 2014-03-10 11:24:31 -0700 | [diff] [blame] | 4 | * Yingdi Yu |
5 | * | ||||
6 | * BSD license, See the LICENSE file for more information | ||||
7 | * | ||||
8 | * Author: Yingdi Yu <yingdi@cs.ucla.edu> | ||||
9 | */ | ||||
10 | |||||
Yingdi Yu | eb692ac | 2015-02-10 18:46:18 -0800 | [diff] [blame] | 11 | #ifndef CHRONOCHAT_TRUST_TREE_NODE_HPP |
12 | #define CHRONOCHAT_TRUST_TREE_NODE_HPP | ||||
Yingdi Yu | f4aaa8b | 2014-03-10 11:24:31 -0700 | [diff] [blame] | 13 | |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 14 | #include "common.hpp" |
15 | |||||
Yingdi Yu | eb692ac | 2015-02-10 18:46:18 -0800 | [diff] [blame] | 16 | namespace chronochat { |
Yingdi Yu | f4aaa8b | 2014-03-10 11:24:31 -0700 | [diff] [blame] | 17 | |
18 | class TrustTreeNode; | ||||
19 | |||||
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 20 | typedef std::vector<shared_ptr<TrustTreeNode> > TrustTreeNodeList; |
Yingdi Yu | f4aaa8b | 2014-03-10 11:24:31 -0700 | [diff] [blame] | 21 | |
22 | class TrustTreeNode | ||||
23 | { | ||||
24 | public: | ||||
25 | TrustTreeNode() | ||||
26 | : m_level(-1) | ||||
27 | , m_visited(false) | ||||
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 28 | { |
29 | } | ||||
Yingdi Yu | f4aaa8b | 2014-03-10 11:24:31 -0700 | [diff] [blame] | 30 | |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 31 | TrustTreeNode(const Name& name) |
Yingdi Yu | f4aaa8b | 2014-03-10 11:24:31 -0700 | [diff] [blame] | 32 | : m_name(name) |
33 | , m_level(-1) | ||||
34 | , m_visited(false) | ||||
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 35 | { |
36 | } | ||||
Yingdi Yu | fa0b6a0 | 2014-04-30 14:26:42 -0700 | [diff] [blame] | 37 | |
Yingdi Yu | f4aaa8b | 2014-03-10 11:24:31 -0700 | [diff] [blame] | 38 | ~TrustTreeNode() |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 39 | { |
40 | } | ||||
Yingdi Yu | f4aaa8b | 2014-03-10 11:24:31 -0700 | [diff] [blame] | 41 | |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 42 | const Name& |
Yingdi Yu | f4aaa8b | 2014-03-10 11:24:31 -0700 | [diff] [blame] | 43 | name() |
44 | { | ||||
45 | return m_name; | ||||
46 | } | ||||
47 | |||||
48 | void | ||||
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 49 | addIntroducee(const shared_ptr<TrustTreeNode>& introducee) |
Yingdi Yu | f4aaa8b | 2014-03-10 11:24:31 -0700 | [diff] [blame] | 50 | { |
51 | m_introducees.push_back(introducee); | ||||
52 | } | ||||
53 | |||||
54 | TrustTreeNodeList& | ||||
55 | getIntroducees() | ||||
56 | { | ||||
57 | return m_introducees; | ||||
58 | } | ||||
59 | |||||
60 | void | ||||
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 61 | addIntroducer(const shared_ptr<TrustTreeNode>& introducer) |
Yingdi Yu | f4aaa8b | 2014-03-10 11:24:31 -0700 | [diff] [blame] | 62 | { |
63 | m_introducers.push_back(introducer); | ||||
64 | } | ||||
65 | |||||
66 | TrustTreeNodeList& | ||||
67 | getIntroducers() | ||||
68 | { | ||||
69 | return m_introducers; | ||||
70 | } | ||||
71 | |||||
72 | void | ||||
73 | setLevel(int level) | ||||
74 | { | ||||
75 | m_level = level; | ||||
76 | } | ||||
77 | |||||
78 | int | ||||
79 | level() | ||||
80 | { | ||||
81 | return m_level; | ||||
82 | } | ||||
83 | |||||
84 | void | ||||
85 | setVisited() | ||||
86 | { | ||||
87 | m_visited = true; | ||||
88 | } | ||||
89 | |||||
90 | void | ||||
91 | resetVisited() | ||||
92 | { | ||||
93 | m_visited = false; | ||||
94 | } | ||||
95 | |||||
96 | bool | ||||
97 | visited() | ||||
98 | { | ||||
99 | return m_visited; | ||||
100 | } | ||||
101 | |||||
102 | public: | ||||
103 | double x; | ||||
104 | double y; | ||||
105 | |||||
106 | private: | ||||
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 107 | Name m_name; |
Yingdi Yu | f4aaa8b | 2014-03-10 11:24:31 -0700 | [diff] [blame] | 108 | TrustTreeNodeList m_introducees; |
109 | TrustTreeNodeList m_introducers; | ||||
110 | int m_level; | ||||
111 | bool m_visited; | ||||
112 | }; | ||||
113 | |||||
Yingdi Yu | eb692ac | 2015-02-10 18:46:18 -0800 | [diff] [blame] | 114 | } // namespace chronochat |
Yingdi Yu | f4aaa8b | 2014-03-10 11:24:31 -0700 | [diff] [blame] | 115 | |
Yingdi Yu | eb692ac | 2015-02-10 18:46:18 -0800 | [diff] [blame] | 116 | #endif // CHRONOCHAT_TRUST_TREE_NODE_HPP |