control_node.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2015-2018 Michele Colledanchise - All Rights Reserved
2  * Copyright (C) 2018 Davide Faconti - All Rights Reserved
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
6 * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
10 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
11 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12 */
13 
15 
16 namespace BT
17 {
18 ControlNode::ControlNode(const std::string& name, const NodeParameters& parameters)
19  : TreeNode::TreeNode(name, parameters)
20 {
21  // TODO(...) In case it is desired to set to idle remove the ReturnStatus
22  // type in order to set the member variable
23  // ReturnStatus const NodeStatus child_status = NodeStatus::IDLE; // commented out as unused
24 }
25 
27 {
28  // Checking if the child is not already present
29  // for (auto node : children_nodes_)
30  // {
31  // if (node == child)
32  // {
33  // throw BehaviorTreeException("'" + child->name() + "' is already a '" + name() + "' child.");
34  // }
35  // }
36 
37  children_nodes_.push_back(child);
38 }
39 
40 unsigned int ControlNode::childrenCount() const
41 {
42  return children_nodes_.size();
43 }
44 
46 {
47  haltChildren(0);
49 }
50 
51 const std::vector<TreeNode*>& ControlNode::children() const
52 {
53  return children_nodes_;
54 }
55 
57 {
58  for (unsigned int j = i; j < children_nodes_.size(); j++)
59  {
60  auto child = children_nodes_[j];
62  {
63  child->halt();
64  }
66  }
67 }
68 }
virtual void halt()=0
The method used to interrupt the execution of a RUNNING node.
std::vector< TreeNode * > children_nodes_
Definition: control_node.h:26
virtual void halt() override
The method used to interrupt the execution of a RUNNING node.
const std::vector< TreeNode * > & children() const
void haltChildren(int i)
unsigned int childrenCount() const
std::unordered_map< std::string, std::string > NodeParameters
Definition: tree_node.h:33
void addChild(TreeNode *child)
NodeStatus status() const
Definition: tree_node.cpp:75
const TreeNode * child(unsigned index) const
Definition: control_node.h:42
ControlNode(const std::string &name, const NodeParameters &parameters)
void setStatus(NodeStatus new_status)
Definition: tree_node.cpp:43


behaviortree_cpp
Author(s): Michele Colledanchise, Davide Faconti
autogenerated on Sun Feb 3 2019 03:14:32