Skip to content

Commit

Permalink
fix and warnings added
Browse files Browse the repository at this point in the history
  • Loading branch information
facontidavide committed Jan 25, 2023
1 parent 9d7576d commit d9c0a40
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/behaviortree_cpp_v3/bt_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ inline TreeNodeManifest CreateManifest(const std::string& ID,
#endif

#else
#define BTCPP_EXPORT
#define BTCPP_EXPORT static
#endif
/* Use this macro to automatically register one or more custom Nodes
* into a factory. For instance:
Expand All @@ -110,7 +110,7 @@ inline TreeNodeManifest CreateManifest(const std::string& ID,
*/

#define BT_REGISTER_NODES(factory) \
static BTCPP_EXPORT void BT_RegisterNodesFromPlugin(BT::BehaviorTreeFactory& factory)
BTCPP_EXPORT void BT_RegisterNodesFromPlugin(BT::BehaviorTreeFactory& factory)

constexpr const char* PLUGIN_SYMBOL = "BT_RegisterNodesFromPlugin";

Expand Down
15 changes: 15 additions & 0 deletions src/bt_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,13 @@ const std::set<std::string>& BehaviorTreeFactory::builtinNodes() const
Tree BehaviorTreeFactory::createTreeFromText(const std::string& text,
Blackboard::Ptr blackboard)
{
if(!parser_->registeredBehaviorTrees().empty()) {
std::cout << "WARNING: You executed BehaviorTreeFactory::createTreeFromText "
"after registerBehaviorTreeFrom[File/Text].\n"
"This is NOTm probably, what you want to do.\n"
"You should probably use BehaviorTreeFactory::createTree, instead"
<< std::endl;
}
XMLParser parser(*this);
parser.loadFromText(text);
auto tree = parser.instantiateTree(blackboard);
Expand All @@ -288,6 +295,14 @@ Tree BehaviorTreeFactory::createTreeFromText(const std::string& text,
Tree BehaviorTreeFactory::createTreeFromFile(const std::string& file_path,
Blackboard::Ptr blackboard)
{
if(!parser_->registeredBehaviorTrees().empty()) {
std::cout << "WARNING: You executed BehaviorTreeFactory::createTreeFromFile "
"after registerBehaviorTreeFrom[File/Text].\n"
"This is NOTm probably, what you want to do.\n"
"You should probably use BehaviorTreeFactory::createTree, instead"
<< std::endl;
}

XMLParser parser(*this);
parser.loadFromFile(file_path);
auto tree = parser.instantiateTree(blackboard);
Expand Down

0 comments on commit d9c0a40

Please sign in to comment.