Ember
Loading...
Searching...
No Matches
EmberCore::LibXMLBehaviorTreeParser Class Reference

Thread-safe XML parser using libxml2 for behavior tree files. More...

#include <LibXMLBehaviorTreeParser.h>

Classes

struct  FileParseInfo
 Per-file parsing information for project validation. More...
struct  ParseError
 Error information for parsing failures (enhanced with libxml2 details) More...
struct  ParseResult
 Result of parallel parsing operation. More...
struct  ProjectParseResult
 Result of project parsing operation. More...

Public Member Functions

 LibXMLBehaviorTreeParser ()
 LibXMLBehaviorTreeParser (const ParserConfig &config)
 ~LibXMLBehaviorTreeParser ()
std::shared_ptr< BehaviorTreeParseFromFile (const EmberCore::String &filepath)
std::shared_ptr< BehaviorTreeParseFromString (const EmberCore::String &xml_content)
std::vector< ParseResultParseMultipleFiles (const std::vector< EmberCore::String > &filepaths)
ProjectParseResult ParseProject (BehaviorTreeProject *project)
ProjectParseResult ParseFilesWithSharedRegistry (const std::vector< EmberCore::String > &filepaths)
void SetProgressCallback (IParseProgressCallback *callback)
const std::map< EmberCore::String, TreeImplementationStatus > & GetTreeImplementationStatuses () const
bool IsTreeImplemented (const EmberCore::String &tree_id) const
std::vector< EmberCore::StringGetUnimplementedReferences () const
bool HasErrors () const
const std::vector< ParseError > & GetErrors () const
void ClearErrors ()
EmberCore::String GetMainTreeName () const
const std::map< EmberCore::String, std::shared_ptr< BehaviorTree > > & GetParsedTrees () const
void SetMaxThreads (size_t max_threads)
size_t GetMaxThreads () const
bool IsThreadSafe () const
const ParserConfigGetConfig () const
void SetConfig (const ParserConfig &config)

Private Member Functions

bool ParseXMLDocument (xmlDocPtr doc, const EmberCore::String &source_path="")
std::shared_ptr< BehaviorTreeParseBehaviorTree (xmlNodePtr tree_node)
std::unique_ptr< NodeParseNode (xmlNodePtr xml_node)
std::unique_ptr< NodeParseControlNode (xmlNodePtr xml_node)
std::unique_ptr< NodeParseActionNode (xmlNodePtr xml_node)
std::unique_ptr< NodeParseConditionNode (xmlNodePtr xml_node)
std::unique_ptr< NodeParseDecoratorNode (xmlNodePtr xml_node)
std::unique_ptr< NodeParseSubTreeNode (xmlNodePtr xml_node)
std::unique_ptr< BlackboardParseBlackboard (xmlNodePtr blackboard_node)
std::unique_ptr< BlackboardEntryParseBlackboardEntry (xmlNodePtr entry_node)
void SetNodeAttributes (Node *node, xmlNodePtr xml_node)
void ParseChildNodes (Node *parent, xmlNodePtr xml_parent)
void CaptureComments (xmlNodePtr parent, BehaviorTree *tree, Node *node=nullptr)
void ExpandAllSubTreePlaceholders ()
bool ExpandSubTreePlaceholder (Node *node)
void ExpandAllSubTreePlaceholdersForProject ()
bool ExpandSubTreePlaceholderForProject (Node *node)
void CollectSubTreeReferences (Node *node, std::set< EmberCore::String > &references)
void AddError (ParseError::Type type, const EmberCore::String &message, xmlNodePtr node=nullptr, const EmberCore::String &context="")
EmberCore::String GetNodePath (xmlNodePtr node)
bool ValidateRequiredAttribute (xmlNodePtr node, const EmberCore::String &attr_name)
bool ReportProgress (const EmberCore::String &message, int current=0, int total=0)
EmberCore::String GetNodeName (xmlNodePtr node)
EmberCore::String GetNodeAttribute (xmlNodePtr node, const EmberCore::String &attr_name)
void InitializeLibXML2 ()

Private Attributes

ParserConfig config_
std::mutex errors_mutex_
std::vector< ParseErrorerrors_
EmberCore::String main_tree_name_
std::map< EmberCore::String, std::shared_ptr< BehaviorTree > > parsed_trees_
std::map< EmberCore::String, std::unique_ptr< Blackboard > > parsed_blackboards_
std::set< EmberCore::Stringexpanded_subtree_cache_
std::set< EmberCore::Stringexpansion_stack_
std::set< EmberCore::Stringcircular_references_
EmberCore::String current_file_path_
IParseProgressCallbackprogress_callback_
std::map< EmberCore::String, TreeImplementationStatustree_implementation_statuses_
std::set< EmberCore::Stringunimplemented_references_
bool project_parsing_mode_
size_t max_threads_
bool thread_safe_
bool libxml2_initialized_

Static Private Attributes

static std::once_flag libxml2_init_flag_
static bool global_libxml2_initialized_ = false
static std::mutex destruction_mutex_

Detailed Description

Thread-safe XML parser using libxml2 for behavior tree files.

This parser provides the same interface as XMLBehaviorTreeParser but uses libxml2 for better performance, thread safety, and parallel parsing capabilities.

Features:

  • Thread-safe parsing
  • Sequential batch file processing
  • Better error reporting with line/column information
  • XPath support for complex queries
  • Memory efficient parsing

Definition at line 55 of file LibXMLBehaviorTreeParser.h.

Constructor & Destructor Documentation

◆ LibXMLBehaviorTreeParser() [1/2]

EmberCore::LibXMLBehaviorTreeParser::LibXMLBehaviorTreeParser ( )

Definition at line 18 of file LibXMLBehaviorTreeParser.cpp.

◆ LibXMLBehaviorTreeParser() [2/2]

EmberCore::LibXMLBehaviorTreeParser::LibXMLBehaviorTreeParser ( const ParserConfig & config)
explicit

Definition at line 24 of file LibXMLBehaviorTreeParser.cpp.

◆ ~LibXMLBehaviorTreeParser()

EmberCore::LibXMLBehaviorTreeParser::~LibXMLBehaviorTreeParser ( )

Definition at line 30 of file LibXMLBehaviorTreeParser.cpp.

Member Function Documentation

◆ AddError()

void EmberCore::LibXMLBehaviorTreeParser::AddError ( ParseError::Type type,
const EmberCore::String & message,
xmlNodePtr node = nullptr,
const EmberCore::String & context = "" )
private

Definition at line 1173 of file LibXMLBehaviorTreeParser.cpp.

◆ CaptureComments()

void EmberCore::LibXMLBehaviorTreeParser::CaptureComments ( xmlNodePtr parent,
BehaviorTree * tree,
Node * node = nullptr )
private

Definition at line 1734 of file LibXMLBehaviorTreeParser.cpp.

◆ ClearErrors()

void EmberCore::LibXMLBehaviorTreeParser::ClearErrors ( )

Definition at line 1168 of file LibXMLBehaviorTreeParser.cpp.

◆ CollectSubTreeReferences()

void EmberCore::LibXMLBehaviorTreeParser::CollectSubTreeReferences ( Node * node,
std::set< EmberCore::String > & references )
private

Definition at line 851 of file LibXMLBehaviorTreeParser.cpp.

◆ ExpandAllSubTreePlaceholders()

void EmberCore::LibXMLBehaviorTreeParser::ExpandAllSubTreePlaceholders ( )
private

Definition at line 1615 of file LibXMLBehaviorTreeParser.cpp.

◆ ExpandAllSubTreePlaceholdersForProject()

void EmberCore::LibXMLBehaviorTreeParser::ExpandAllSubTreePlaceholdersForProject ( )
private

Definition at line 876 of file LibXMLBehaviorTreeParser.cpp.

◆ ExpandSubTreePlaceholder()

bool EmberCore::LibXMLBehaviorTreeParser::ExpandSubTreePlaceholder ( Node * node)
private

Definition at line 1628 of file LibXMLBehaviorTreeParser.cpp.

◆ ExpandSubTreePlaceholderForProject()

bool EmberCore::LibXMLBehaviorTreeParser::ExpandSubTreePlaceholderForProject ( Node * node)
private

Definition at line 893 of file LibXMLBehaviorTreeParser.cpp.

◆ GetConfig()

const ParserConfig & EmberCore::LibXMLBehaviorTreeParser::GetConfig ( ) const
inline

Definition at line 191 of file LibXMLBehaviorTreeParser.h.

◆ GetErrors()

const std::vector< LibXMLBehaviorTreeParser::ParseError > & EmberCore::LibXMLBehaviorTreeParser::GetErrors ( ) const

Definition at line 1163 of file LibXMLBehaviorTreeParser.cpp.

◆ GetMainTreeName()

EmberCore::String EmberCore::LibXMLBehaviorTreeParser::GetMainTreeName ( ) const
inline

Definition at line 182 of file LibXMLBehaviorTreeParser.h.

◆ GetMaxThreads()

size_t EmberCore::LibXMLBehaviorTreeParser::GetMaxThreads ( ) const
inline

Definition at line 187 of file LibXMLBehaviorTreeParser.h.

◆ GetNodeAttribute()

EmberCore::String EmberCore::LibXMLBehaviorTreeParser::GetNodeAttribute ( xmlNodePtr node,
const EmberCore::String & attr_name )
private

Definition at line 1144 of file LibXMLBehaviorTreeParser.cpp.

◆ GetNodeName()

EmberCore::String EmberCore::LibXMLBehaviorTreeParser::GetNodeName ( xmlNodePtr node)
private

Definition at line 1138 of file LibXMLBehaviorTreeParser.cpp.

◆ GetNodePath()

EmberCore::String EmberCore::LibXMLBehaviorTreeParser::GetNodePath ( xmlNodePtr node)
private

Definition at line 1193 of file LibXMLBehaviorTreeParser.cpp.

◆ GetParsedTrees()

const std::map< EmberCore::String, std::shared_ptr< BehaviorTree > > & EmberCore::LibXMLBehaviorTreeParser::GetParsedTrees ( ) const
inline

Definition at line 183 of file LibXMLBehaviorTreeParser.h.

◆ GetTreeImplementationStatuses()

const std::map< EmberCore::String, TreeImplementationStatus > & EmberCore::LibXMLBehaviorTreeParser::GetTreeImplementationStatuses ( ) const
inline

Definition at line 166 of file LibXMLBehaviorTreeParser.h.

◆ GetUnimplementedReferences()

std::vector< EmberCore::String > EmberCore::LibXMLBehaviorTreeParser::GetUnimplementedReferences ( ) const

Definition at line 990 of file LibXMLBehaviorTreeParser.cpp.

◆ HasErrors()

bool EmberCore::LibXMLBehaviorTreeParser::HasErrors ( ) const

Definition at line 1158 of file LibXMLBehaviorTreeParser.cpp.

◆ InitializeLibXML2()

void EmberCore::LibXMLBehaviorTreeParser::InitializeLibXML2 ( )
private

Definition at line 51 of file LibXMLBehaviorTreeParser.cpp.

◆ IsThreadSafe()

bool EmberCore::LibXMLBehaviorTreeParser::IsThreadSafe ( ) const
inline

Definition at line 188 of file LibXMLBehaviorTreeParser.h.

◆ IsTreeImplemented()

bool EmberCore::LibXMLBehaviorTreeParser::IsTreeImplemented ( const EmberCore::String & tree_id) const

Definition at line 982 of file LibXMLBehaviorTreeParser.cpp.

◆ ParseActionNode()

std::unique_ptr< Node > EmberCore::LibXMLBehaviorTreeParser::ParseActionNode ( xmlNodePtr xml_node)
private

Definition at line 1375 of file LibXMLBehaviorTreeParser.cpp.

◆ ParseBehaviorTree()

std::shared_ptr< BehaviorTree > EmberCore::LibXMLBehaviorTreeParser::ParseBehaviorTree ( xmlNodePtr tree_node)
private

Definition at line 1231 of file LibXMLBehaviorTreeParser.cpp.

◆ ParseBlackboard()

std::unique_ptr< Blackboard > EmberCore::LibXMLBehaviorTreeParser::ParseBlackboard ( xmlNodePtr blackboard_node)
private

Definition at line 1477 of file LibXMLBehaviorTreeParser.cpp.

◆ ParseBlackboardEntry()

std::unique_ptr< BlackboardEntry > EmberCore::LibXMLBehaviorTreeParser::ParseBlackboardEntry ( xmlNodePtr entry_node)
private

Definition at line 1512 of file LibXMLBehaviorTreeParser.cpp.

◆ ParseChildNodes()

void EmberCore::LibXMLBehaviorTreeParser::ParseChildNodes ( Node * parent,
xmlNodePtr xml_parent )
private

Definition at line 1588 of file LibXMLBehaviorTreeParser.cpp.

◆ ParseConditionNode()

std::unique_ptr< Node > EmberCore::LibXMLBehaviorTreeParser::ParseConditionNode ( xmlNodePtr xml_node)
private

Definition at line 1401 of file LibXMLBehaviorTreeParser.cpp.

◆ ParseControlNode()

std::unique_ptr< Node > EmberCore::LibXMLBehaviorTreeParser::ParseControlNode ( xmlNodePtr xml_node)
private

Definition at line 1350 of file LibXMLBehaviorTreeParser.cpp.

◆ ParseDecoratorNode()

std::unique_ptr< Node > EmberCore::LibXMLBehaviorTreeParser::ParseDecoratorNode ( xmlNodePtr xml_node)
private

Definition at line 1427 of file LibXMLBehaviorTreeParser.cpp.

◆ ParseFilesWithSharedRegistry()

LibXMLBehaviorTreeParser::ProjectParseResult EmberCore::LibXMLBehaviorTreeParser::ParseFilesWithSharedRegistry ( const std::vector< EmberCore::String > & filepaths)

Definition at line 349 of file LibXMLBehaviorTreeParser.cpp.

◆ ParseFromFile()

std::shared_ptr< BehaviorTree > EmberCore::LibXMLBehaviorTreeParser::ParseFromFile ( const EmberCore::String & filepath)

Definition at line 72 of file LibXMLBehaviorTreeParser.cpp.

◆ ParseFromString()

std::shared_ptr< BehaviorTree > EmberCore::LibXMLBehaviorTreeParser::ParseFromString ( const EmberCore::String & xml_content)

Definition at line 212 of file LibXMLBehaviorTreeParser.cpp.

◆ ParseMultipleFiles()

std::vector< LibXMLBehaviorTreeParser::ParseResult > EmberCore::LibXMLBehaviorTreeParser::ParseMultipleFiles ( const std::vector< EmberCore::String > & filepaths)

Definition at line 278 of file LibXMLBehaviorTreeParser.cpp.

◆ ParseNode()

std::unique_ptr< Node > EmberCore::LibXMLBehaviorTreeParser::ParseNode ( xmlNodePtr xml_node)
private

Definition at line 1295 of file LibXMLBehaviorTreeParser.cpp.

◆ ParseProject()

LibXMLBehaviorTreeParser::ProjectParseResult EmberCore::LibXMLBehaviorTreeParser::ParseProject ( BehaviorTreeProject * project)

Definition at line 324 of file LibXMLBehaviorTreeParser.cpp.

◆ ParseSubTreeNode()

std::unique_ptr< Node > EmberCore::LibXMLBehaviorTreeParser::ParseSubTreeNode ( xmlNodePtr xml_node)
private

Definition at line 1452 of file LibXMLBehaviorTreeParser.cpp.

◆ ParseXMLDocument()

bool EmberCore::LibXMLBehaviorTreeParser::ParseXMLDocument ( xmlDocPtr doc,
const EmberCore::String & source_path = "" )
private

Definition at line 1002 of file LibXMLBehaviorTreeParser.cpp.

◆ ReportProgress()

bool EmberCore::LibXMLBehaviorTreeParser::ReportProgress ( const EmberCore::String & message,
int current = 0,
int total = 0 )
private

Definition at line 1223 of file LibXMLBehaviorTreeParser.cpp.

◆ SetConfig()

void EmberCore::LibXMLBehaviorTreeParser::SetConfig ( const ParserConfig & config)
inline

Definition at line 192 of file LibXMLBehaviorTreeParser.h.

◆ SetMaxThreads()

void EmberCore::LibXMLBehaviorTreeParser::SetMaxThreads ( size_t max_threads)
inline

Definition at line 186 of file LibXMLBehaviorTreeParser.h.

◆ SetNodeAttributes()

void EmberCore::LibXMLBehaviorTreeParser::SetNodeAttributes ( Node * node,
xmlNodePtr xml_node )
private

Definition at line 1550 of file LibXMLBehaviorTreeParser.cpp.

◆ SetProgressCallback()

void EmberCore::LibXMLBehaviorTreeParser::SetProgressCallback ( IParseProgressCallback * callback)
inline

Definition at line 163 of file LibXMLBehaviorTreeParser.h.

◆ ValidateRequiredAttribute()

bool EmberCore::LibXMLBehaviorTreeParser::ValidateRequiredAttribute ( xmlNodePtr node,
const EmberCore::String & attr_name )
private

Definition at line 1719 of file LibXMLBehaviorTreeParser.cpp.

Member Data Documentation

◆ circular_references_

std::set<EmberCore::String> EmberCore::LibXMLBehaviorTreeParser::circular_references_
private

Definition at line 257 of file LibXMLBehaviorTreeParser.h.

◆ config_

ParserConfig EmberCore::LibXMLBehaviorTreeParser::config_
private

Definition at line 247 of file LibXMLBehaviorTreeParser.h.

◆ current_file_path_

EmberCore::String EmberCore::LibXMLBehaviorTreeParser::current_file_path_
private

Definition at line 258 of file LibXMLBehaviorTreeParser.h.

◆ destruction_mutex_

std::mutex EmberCore::LibXMLBehaviorTreeParser::destruction_mutex_
staticprivate

Definition at line 276 of file LibXMLBehaviorTreeParser.h.

◆ errors_

std::vector<ParseError> EmberCore::LibXMLBehaviorTreeParser::errors_
private

Definition at line 251 of file LibXMLBehaviorTreeParser.h.

◆ errors_mutex_

std::mutex EmberCore::LibXMLBehaviorTreeParser::errors_mutex_
mutableprivate

Definition at line 250 of file LibXMLBehaviorTreeParser.h.

◆ expanded_subtree_cache_

std::set<EmberCore::String> EmberCore::LibXMLBehaviorTreeParser::expanded_subtree_cache_
private

Definition at line 255 of file LibXMLBehaviorTreeParser.h.

◆ expansion_stack_

std::set<EmberCore::String> EmberCore::LibXMLBehaviorTreeParser::expansion_stack_
private

Definition at line 256 of file LibXMLBehaviorTreeParser.h.

◆ global_libxml2_initialized_

bool EmberCore::LibXMLBehaviorTreeParser::global_libxml2_initialized_ = false
staticprivate

Definition at line 273 of file LibXMLBehaviorTreeParser.h.

◆ libxml2_init_flag_

std::once_flag EmberCore::LibXMLBehaviorTreeParser::libxml2_init_flag_
staticprivate

Definition at line 272 of file LibXMLBehaviorTreeParser.h.

◆ libxml2_initialized_

bool EmberCore::LibXMLBehaviorTreeParser::libxml2_initialized_
private

Definition at line 269 of file LibXMLBehaviorTreeParser.h.

◆ main_tree_name_

EmberCore::String EmberCore::LibXMLBehaviorTreeParser::main_tree_name_
private

Definition at line 252 of file LibXMLBehaviorTreeParser.h.

◆ max_threads_

size_t EmberCore::LibXMLBehaviorTreeParser::max_threads_
private

Definition at line 267 of file LibXMLBehaviorTreeParser.h.

◆ parsed_blackboards_

std::map<EmberCore::String, std::unique_ptr<Blackboard> > EmberCore::LibXMLBehaviorTreeParser::parsed_blackboards_
private

Definition at line 254 of file LibXMLBehaviorTreeParser.h.

◆ parsed_trees_

std::map<EmberCore::String, std::shared_ptr<BehaviorTree> > EmberCore::LibXMLBehaviorTreeParser::parsed_trees_
private

Definition at line 253 of file LibXMLBehaviorTreeParser.h.

◆ progress_callback_

IParseProgressCallback* EmberCore::LibXMLBehaviorTreeParser::progress_callback_
private

Definition at line 259 of file LibXMLBehaviorTreeParser.h.

◆ project_parsing_mode_

bool EmberCore::LibXMLBehaviorTreeParser::project_parsing_mode_
private

Definition at line 264 of file LibXMLBehaviorTreeParser.h.

◆ thread_safe_

bool EmberCore::LibXMLBehaviorTreeParser::thread_safe_
private

Definition at line 268 of file LibXMLBehaviorTreeParser.h.

◆ tree_implementation_statuses_

std::map<EmberCore::String, TreeImplementationStatus> EmberCore::LibXMLBehaviorTreeParser::tree_implementation_statuses_
private

Definition at line 262 of file LibXMLBehaviorTreeParser.h.

◆ unimplemented_references_

std::set<EmberCore::String> EmberCore::LibXMLBehaviorTreeParser::unimplemented_references_
private

Definition at line 263 of file LibXMLBehaviorTreeParser.h.


The documentation for this class was generated from the following files: