Go to the documentation of this file.00001 #ifndef BT_BASIC_TYPES_H
00002 #define BT_BASIC_TYPES_H
00003
00004 #include <iostream>
00005 #include <string>
00006 #include <stdexcept>
00007 #include <vector>
00008 #include <sstream>
00009 #include <exception>
00010 #include "behaviortree_cpp/string_view.hpp"
00011 #include "behaviortree_cpp/blackboard/demangle_util.h"
00012
00013 namespace BT
00014 {
00015
00016 enum class NodeType
00017 {
00018 UNDEFINED = 0,
00019 ACTION,
00020 CONDITION,
00021 CONTROL,
00022 DECORATOR,
00023 SUBTREE
00024 };
00025
00026
00027
00028 enum class NodeStatus
00029 {
00030 IDLE = 0,
00031 RUNNING,
00032 SUCCESS,
00033 FAILURE
00034 };
00035
00036
00037
00038
00039
00040
00041 enum FailurePolicy
00042 {
00043 FAIL_ON_ONE,
00044 FAIL_ON_ALL
00045 };
00046
00047
00048
00049
00050
00051
00052 enum SuccessPolicy
00053 {
00054 SUCCEED_ON_ONE,
00055 SUCCEED_ON_ALL
00056 };
00057
00058 typedef nonstd::string_view StringView;
00059
00063 template <typename T> inline
00064 T convertFromString(const StringView& )
00065 {
00066 auto type_name = BT::demangle( typeid(T).name() );
00067
00068 std::cerr << "You (maybe indirectly) called BT::convertFromString() for type [" <<
00069 type_name <<"], but I can't find the template specialization.\n" << std::endl;
00070
00071 throw std::logic_error(std::string("You didn't implement the template specialization of "
00072 "convertFromString for this type: ") + type_name );
00073 }
00074
00075 template <>
00076 std::string convertFromString<std::string>(const StringView& str);
00077
00078 template <>
00079 const char* convertFromString<const char*>(const StringView& str);
00080
00081 template <>
00082 int convertFromString<int>(const StringView& str);
00083
00084 template <>
00085 unsigned convertFromString<unsigned>(const StringView& str);
00086
00087 template <>
00088 double convertFromString<double>(const StringView& str);
00089
00090 template <>
00091 std::vector<int> convertFromString<std::vector<int>>(const StringView& str);
00092
00093 template <>
00094 std::vector<double> convertFromString<std::vector<double>>(const StringView& str);
00095
00096 template <>
00097 bool convertFromString<bool>(const StringView& str);
00098
00099 template <>
00100 NodeStatus convertFromString<NodeStatus>(const StringView& str);
00101
00102 template <>
00103 NodeType convertFromString<NodeType>(const StringView& str);
00104
00105
00106
00107
00111 const char* toStr(const BT::NodeStatus& status, bool colored = false);
00112
00113 std::ostream& operator<<(std::ostream& os, const BT::NodeStatus& status);
00114
00118 const char* toStr(const BT::NodeType& type);
00119
00120 std::ostream& operator<<(std::ostream& os, const BT::NodeType& type);
00121
00122
00123
00124 std::vector<StringView> splitString(const StringView& strToSplit, char delimeter);
00125 }
00126
00127 #endif // BT_BASIC_TYPES_H