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