* Set the root node, only once. * @param {string} node_id * @param {string} topic * @param {Record =} data * @returns {Node | null}
(node_id, topic, data)
| 48 | * @returns {Node | null} |
| 49 | */ |
| 50 | set_root(node_id, topic, data) { |
| 51 | if (this.root == null) { |
| 52 | this.root = new Node(node_id, 0, topic, data, true); |
| 53 | this._put_node(this.root); |
| 54 | return this.root; |
| 55 | } else { |
| 56 | logger.error('root node is already exist'); |
| 57 | return null; |
| 58 | } |
| 59 | } |
| 60 | /** |
| 61 | * Add a child node under parent. |
| 62 | * @param {Node} parent_node |