blob: cb275b2cfd11062b415145089cdb3067f3ae418b [file] [log] [blame]
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -07001/* -*- 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
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -07004 * 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 Yueb692ac2015-02-10 18:46:18 -080011#ifndef CHRONOCHAT_TRUST_TREE_NODE_HPP
12#define CHRONOCHAT_TRUST_TREE_NODE_HPP
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -070013
Yingdi Yu0b0a7362014-08-05 16:31:30 -070014#include "common.hpp"
15
Yingdi Yueb692ac2015-02-10 18:46:18 -080016namespace chronochat {
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -070017
18class TrustTreeNode;
19
Yingdi Yu0b0a7362014-08-05 16:31:30 -070020typedef std::vector<shared_ptr<TrustTreeNode> > TrustTreeNodeList;
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -070021
22class TrustTreeNode
23{
24public:
25 TrustTreeNode()
26 : m_level(-1)
27 , m_visited(false)
Yingdi Yu0b0a7362014-08-05 16:31:30 -070028 {
29 }
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -070030
Yingdi Yu0b0a7362014-08-05 16:31:30 -070031 TrustTreeNode(const Name& name)
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -070032 : m_name(name)
33 , m_level(-1)
34 , m_visited(false)
Yingdi Yu0b0a7362014-08-05 16:31:30 -070035 {
36 }
Yingdi Yufa0b6a02014-04-30 14:26:42 -070037
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -070038 ~TrustTreeNode()
Yingdi Yu0b0a7362014-08-05 16:31:30 -070039 {
40 }
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -070041
Yingdi Yu0b0a7362014-08-05 16:31:30 -070042 const Name&
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -070043 name()
44 {
45 return m_name;
46 }
47
48 void
Yingdi Yu0b0a7362014-08-05 16:31:30 -070049 addIntroducee(const shared_ptr<TrustTreeNode>& introducee)
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -070050 {
51 m_introducees.push_back(introducee);
52 }
53
54 TrustTreeNodeList&
55 getIntroducees()
56 {
57 return m_introducees;
58 }
59
60 void
Yingdi Yu0b0a7362014-08-05 16:31:30 -070061 addIntroducer(const shared_ptr<TrustTreeNode>& introducer)
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -070062 {
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
102public:
103 double x;
104 double y;
105
106private:
Yingdi Yu0b0a7362014-08-05 16:31:30 -0700107 Name m_name;
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -0700108 TrustTreeNodeList m_introducees;
109 TrustTreeNodeList m_introducers;
110 int m_level;
111 bool m_visited;
112};
113
Yingdi Yueb692ac2015-02-10 18:46:18 -0800114} // namespace chronochat
Yingdi Yuf4aaa8b2014-03-10 11:24:31 -0700115
Yingdi Yueb692ac2015-02-10 18:46:18 -0800116#endif // CHRONOCHAT_TRUST_TREE_NODE_HPP