Skip to content

Commit 5d59bb2

Browse files
committedSep 29, 2022
new clang format
1 parent 390257c commit 5d59bb2

File tree

82 files changed

+6370
-5798
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+6370
-5798
lines changed
 

‎.clang-format

+6-4
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ AlwaysBreakTemplateDeclarations: true
1313
AlwaysBreakBeforeMultilineStrings: false
1414
BreakBeforeBinaryOperators: false
1515
BreakBeforeTernaryOperators: false
16-
BreakConstructorInitializersBeforeComma: true
16+
BreakConstructorInitializersBeforeComma: false
17+
BreakConstructorInitializers: AfterColon
1718
BinPackParameters: true
18-
ColumnLimit: 100
19+
ColumnLimit: 90
1920
ConstructorInitializerAllOnOneLineOrOnePerLine: true
2021
DerivePointerBinding: false
2122
PointerBindsToType: true
@@ -33,8 +34,8 @@ PenaltyReturnTypeOnItsOwnLine: 90
3334
SpacesBeforeTrailingComments: 3
3435
Cpp11BracedListStyle: true
3536
Standard: Auto
36-
IndentWidth: 4
37-
TabWidth: 4
37+
IndentWidth: 2
38+
TabWidth: 2
3839
UseTab: Never
3940
IndentFunctionDeclarationAfterType: false
4041
SpacesInParentheses: false
@@ -63,6 +64,7 @@ BraceWrapping: {
6364
BeforeCatch : 'true'
6465
BeforeElse : 'true'
6566
IndentBraces : 'false'
67+
SplitEmptyFunction: 'false'
6668
}
6769
...
6870

‎include/behaviortree_cpp_v3/action_node.h

+78-86
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
namespace BT
2525
{
26-
2726
// IMPORTANT: Actions which returned SUCCESS or FAILURE will not be ticked
2827
// again unless resetStatus() is called first.
2928
// Keep this in mind when writing your custom Control and Decorator nodes.
@@ -35,15 +34,14 @@ namespace BT
3534
*/
3635
class ActionNodeBase : public LeafNode
3736
{
38-
public:
39-
40-
ActionNodeBase(const std::string& name, const NodeConfiguration& config);
41-
~ActionNodeBase() override = default;
42-
43-
virtual NodeType type() const override final
44-
{
45-
return NodeType::ACTION;
46-
}
37+
public:
38+
ActionNodeBase(const std::string& name, const NodeConfiguration& config);
39+
~ActionNodeBase() override = default;
40+
41+
virtual NodeType type() const override final
42+
{
43+
return NodeType::ACTION;
44+
}
4745
};
4846

4947
/**
@@ -53,17 +51,16 @@ class ActionNodeBase : public LeafNode
5351
*/
5452
class SyncActionNode : public ActionNodeBase
5553
{
56-
public:
57-
58-
SyncActionNode(const std::string& name, const NodeConfiguration& config);
59-
~SyncActionNode() override = default;
54+
public:
55+
SyncActionNode(const std::string& name, const NodeConfiguration& config);
56+
~SyncActionNode() override = default;
6057

61-
/// throws if the derived class return RUNNING.
62-
virtual NodeStatus executeTick() override;
58+
/// throws if the derived class return RUNNING.
59+
virtual NodeStatus executeTick() override;
6360

64-
/// You don't need to override this
65-
virtual void halt() override final
66-
{ }
61+
/// You don't need to override this
62+
virtual void halt() override final
63+
{}
6764
};
6865

6966
/**
@@ -80,19 +77,19 @@ class SyncActionNode : public ActionNodeBase
8077
*/
8178
class SimpleActionNode : public SyncActionNode
8279
{
83-
public:
84-
typedef std::function<NodeStatus(TreeNode&)> TickFunctor;
80+
public:
81+
typedef std::function<NodeStatus(TreeNode&)> TickFunctor;
8582

86-
// You must provide the function to call when tick() is invoked
87-
SimpleActionNode(const std::string& name, TickFunctor tick_functor,
88-
const NodeConfiguration& config);
83+
// You must provide the function to call when tick() is invoked
84+
SimpleActionNode(const std::string& name, TickFunctor tick_functor,
85+
const NodeConfiguration& config);
8986

90-
~SimpleActionNode() override = default;
87+
~SimpleActionNode() override = default;
9188

92-
protected:
93-
virtual NodeStatus tick() override final;
89+
protected:
90+
virtual NodeStatus tick() override final;
9491

95-
TickFunctor tick_functor_;
92+
TickFunctor tick_functor_;
9693
};
9794

9895
/**
@@ -116,28 +113,26 @@ class SimpleActionNode : public SyncActionNode
116113
*/
117114
class AsyncActionNode : public ActionNodeBase
118115
{
119-
public:
120-
121-
AsyncActionNode(const std::string& name, const NodeConfiguration& config):ActionNodeBase(name, config)
122-
{
123-
}
124-
125-
bool isHaltRequested() const
126-
{
127-
return halt_requested_.load();
128-
}
129-
130-
// This method spawn a new thread. Do NOT remove the "final" keyword.
131-
virtual NodeStatus executeTick() override final;
132-
133-
virtual void halt() override;
134-
135-
private:
136-
137-
std::exception_ptr exptr_;
138-
std::atomic_bool halt_requested_;
139-
std::future<void> thread_handle_;
140-
std::mutex mutex_;
116+
public:
117+
AsyncActionNode(const std::string& name, const NodeConfiguration& config) :
118+
ActionNodeBase(name, config)
119+
{}
120+
121+
bool isHaltRequested() const
122+
{
123+
return halt_requested_.load();
124+
}
125+
126+
// This method spawn a new thread. Do NOT remove the "final" keyword.
127+
virtual NodeStatus executeTick() override final;
128+
129+
virtual void halt() override;
130+
131+
private:
132+
std::exception_ptr exptr_;
133+
std::atomic_bool halt_requested_;
134+
std::future<void> thread_handle_;
135+
std::mutex mutex_;
141136
};
142137

143138
/**
@@ -157,29 +152,28 @@ class AsyncActionNode : public ActionNodeBase
157152
*/
158153
class StatefulActionNode : public ActionNodeBase
159154
{
160-
public:
161-
StatefulActionNode(const std::string& name, const NodeConfiguration& config):
162-
ActionNodeBase(name,config)
163-
{}
164-
165-
// do not override this method
166-
NodeStatus tick() override final;
167-
// do not override this method
168-
void halt() override final;
169-
170-
/// method to be called at the beginning.
171-
/// If it returns RUNNING, this becomes an asychronous node.
172-
virtual NodeStatus onStart() = 0;
173-
174-
/// method invoked by a RUNNING action.
175-
virtual NodeStatus onRunning() = 0;
176-
177-
/// when the method halt() is called and the action is RUNNING, this method is invoked.
178-
/// This is a convenient place todo a cleanup, if needed.
179-
virtual void onHalted() = 0;
155+
public:
156+
StatefulActionNode(const std::string& name, const NodeConfiguration& config) :
157+
ActionNodeBase(name, config)
158+
{}
159+
160+
// do not override this method
161+
NodeStatus tick() override final;
162+
// do not override this method
163+
void halt() override final;
164+
165+
/// method to be called at the beginning.
166+
/// If it returns RUNNING, this becomes an asychronous node.
167+
virtual NodeStatus onStart() = 0;
168+
169+
/// method invoked by a RUNNING action.
170+
virtual NodeStatus onRunning() = 0;
171+
172+
/// when the method halt() is called and the action is RUNNING, this method is invoked.
173+
/// This is a convenient place todo a cleanup, if needed.
174+
virtual void onHalted() = 0;
180175
};
181176

182-
183177
#ifndef BT_NO_COROUTINES
184178

185179
/**
@@ -191,18 +185,17 @@ class StatefulActionNode : public ActionNodeBase
191185
*/
192186
class CoroActionNode : public ActionNodeBase
193187
{
194-
public:
195-
196-
CoroActionNode(const std::string& name, const NodeConfiguration& config);
197-
virtual ~CoroActionNode() override;
188+
public:
189+
CoroActionNode(const std::string& name, const NodeConfiguration& config);
190+
virtual ~CoroActionNode() override;
198191

199-
/// Use this method to return RUNNING and temporary "pause" the Action.
200-
void setStatusRunningAndYield();
192+
/// Use this method to return RUNNING and temporary "pause" the Action.
193+
void setStatusRunningAndYield();
201194

202-
// This method triggers the TickEngine. Do NOT remove the "final" keyword.
203-
virtual NodeStatus executeTick() override final;
195+
// This method triggers the TickEngine. Do NOT remove the "final" keyword.
196+
virtual NodeStatus executeTick() override final;
204197

205-
/** You may want to override this method. But still, remember to call this
198+
/** You may want to override this method. But still, remember to call this
206199
* implementation too.
207200
*
208201
* Example:
@@ -213,15 +206,14 @@ class CoroActionNode : public ActionNodeBase
213206
* CoroActionNode::halt();
214207
* }
215208
*/
216-
void halt() override;
217-
218-
protected:
209+
void halt() override;
219210

220-
struct Pimpl; // The Pimpl idiom
221-
std::unique_ptr<Pimpl> _p;
211+
protected:
212+
struct Pimpl; // The Pimpl idiom
213+
std::unique_ptr<Pimpl> _p;
222214
};
223215
#endif
224216

225-
} //end namespace
217+
} // namespace BT
226218

227219
#endif

0 commit comments

Comments
 (0)