Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fd59513

Browse files
author
Davide Faconti
committed
minor update
1 parent f1d89c8 commit fd59513

File tree

4 files changed

+26
-17
lines changed

4 files changed

+26
-17
lines changed

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CONFIG_PATH}")
1515

1616
option(BUILD_EXAMPLES "Build tutorials and examples" ON)
1717
option(BUILD_UNIT_TESTS "Build the unit tests" ON)
18+
option(BUILD_TOOLS "Build commandline tools" ON)
1819

1920
#############################################################
2021
# Find packages
@@ -245,9 +246,11 @@ install(EXPORT ${PROJECT_CONFIG}
245246

246247
######################################################
247248
# EXAMPLES and TOOLS
249+
if(BUILD_TOOLS)
250+
add_subdirectory(tools)
251+
endif()
248252

249253
if( BUILD_EXAMPLES )
250-
add_subdirectory(tools)
251254
add_subdirectory(sample_nodes)
252255
add_subdirectory(examples)
253256
endif()

include/behaviortree_cpp/basic_types.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,11 @@ using Result = Optional<void>;
175175

176176
enum class PortDirection{INPUT, OUTPUT, INOUT };
177177

178+
const char* toStr(PortDirection type);
179+
180+
std::ostream& operator<<(std::ostream& os, const BT::PortDirection& type);
181+
182+
178183
class PortInfo
179184
{
180185

src/basic_types.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,12 @@ std::ostream& operator<<(std::ostream& os, const NodeStatus& status)
186186
return os;
187187
}
188188

189+
std::ostream& operator<<(std::ostream& os, const PortDirection& type)
190+
{
191+
os << toStr(type);
192+
return os;
193+
}
194+
189195
std::vector<StringView> splitString(const StringView &strToSplit, char delimeter)
190196
{
191197
std::vector<StringView> splitted_strings;
@@ -244,5 +250,15 @@ const std::string &PortInfo::description() const
244250
return description_;
245251
}
246252

253+
const char *toStr(PortDirection type)
254+
{
255+
switch(type)
256+
{
257+
case PortDirection::INPUT: return "input_port";
258+
case PortDirection::OUTPUT: return "output_port";
259+
case PortDirection::INOUT: return "input_port";
260+
}
261+
}
262+
247263

248264
} // end namespace

src/xml_parsing.cpp

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -629,22 +629,7 @@ std::string writeTreeNodesModelXML(const BehaviorTreeFactory& factory)
629629
const auto& port_name = port.first;
630630
const auto& port_info = port.second;
631631

632-
XMLElement* port_element = nullptr;
633-
634-
switch( port_info.direction() )
635-
{
636-
case PortDirection::INPUT:
637-
port_element = doc.NewElement("input_port");
638-
break;
639-
640-
case PortDirection::OUTPUT:
641-
port_element = doc.NewElement("input_port");
642-
break;
643-
644-
case PortDirection::INOUT:
645-
port_element = doc.NewElement("inout_port");
646-
break;
647-
}
632+
XMLElement* port_element = doc.NewElement( toStr( port_info.direction()) );
648633

649634
port_element->SetAttribute("name", port_name.c_str() );
650635
if( port_info.type() )

0 commit comments

Comments
 (0)