MCPcopy Create free account
hub / github.com/BehaviorTree/Groot / ReadTreeNodesModel

Function ReadTreeNodesModel

bt_editor/XML_utilities.cpp:83–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81//------------------------------------------------------------------
82
83NodeModels ReadTreeNodesModel(const QDomElement &root)
84{
85 NodeModels models;
86 using QtNodes::DataModelRegistry;
87
88 auto model_root = root.firstChildElement("TreeNodesModel");
89
90 if( !model_root.isNull() )
91 {
92 for( QDomElement node = model_root.firstChildElement();
93 !node.isNull();
94 node = node.nextSiblingElement() )
95 {
96 auto model = buildTreeNodeModelFromXML(node);
97 models.insert( {model.registration_ID, model} );
98 }
99 }
100
101 std::function<void(QDomElement)> recursiveStep;
102 recursiveStep = [&](QDomElement node)
103 {
104 auto model = buildTreeNodeModelFromXML(node);
105 if( model.type != NodeType::UNDEFINED &&
106 model.registration_ID.isEmpty() == false &&
107 models.count(model.registration_ID) == 0)
108 {
109 models.insert( {model.registration_ID, model} );
110 }
111
112 for( QDomElement child = node.firstChildElement();
113 !child.isNull();
114 child = child.nextSiblingElement() )
115 {
116 recursiveStep(child);
117 }
118 };
119
120 for( QDomElement bt_root = root.firstChildElement("BehaviorTree");
121 !bt_root.isNull();
122 bt_root = bt_root.nextSiblingElement("BehaviorTree") )
123 {
124 recursiveStep( bt_root.firstChildElement() );
125 }
126 return models;
127}
128
129
130

Callers 1

loadFromXMLMethod · 0.85

Calls 1

Tested by

no test coverage detected