StateTreeModel.cpp
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5 *
6 * ArmarX is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * ArmarX is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * @package
19 * @author
20 * @date
21 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22 * GNU General Public License
23 */
24#include "StateTreeModel.h"
25
26#include <filesystem>
27
28#include <QMessageBox>
29
37
40#include "../io/XmlWriter.h"
41#include <omp.h>
42
43
44using namespace armarx;
45using namespace statechartio;
46using namespace statechartmodel;
47
49 iceCommunicator(ic), variantInfo(variantInfo)
50{
51 StateTreeNodePtr nullNode;
52 StatechartGroupPtr nullGroup;
53 this->rootNode.reset(
54 new StateTreeNode(QString(), "", StateTreeNode::Folder, nullNode, nullGroup, false));
55}
56
57void
59{
60 QList<statechartmodel::StatePtr> statesToAnnotate;
61
62 for (int i = 0; i < groups.count(); i++)
63 {
64 StatechartGroupPtr group = groups.at(i);
65 ARMARX_INFO_S << "loading group " << group->getName();
66
67 for (int j = 0; j < group->getRootNode()->getChildren().count(); j++)
68 {
69 loadNode(group->getRootNode()->getChildren().at(j),
70 group->getBoostGroupPath(),
71 statesToAnnotate);
72 }
73 }
74
76}
77
78void
80{
81 QList<statechartmodel::StatePtr> statesToAnnotate;
82
83 for (int j = 0; j < group->getRootNode()->getChildren().count(); j++)
84 {
85 loadNode(group->getRootNode()->getChildren().at(j),
86 group->getBoostGroupPath(),
87 statesToAnnotate);
88 }
89
91}
92
93void
94StateTreeModel::annotateStateRerefences(const QList<statechartmodel::StatePtr>& statesToAnnotate)
95{
96 QMap<QString, statechartmodel::StatePtr> referenceMap;
97 QMapIterator<QString, StateTreeNodePtr> i(uuidToNodeMap);
98
99 while (i.hasNext())
100 {
101 i.next();
102 referenceMap.insert(i.key(), i.value()->getState());
103 }
104
105 for (int i = 0; i < statesToAnnotate.count(); i++)
106 {
107 statesToAnnotate.at(i)->addReferences(referenceMap);
108 }
109}
110
111void
113{
114 QMap<QString, statechartmodel::StatePtr> referenceMap;
115 QMapIterator<QString, StateTreeNodePtr> i(uuidToNodeMap);
116
117 while (i.hasNext())
118 {
119 i.next();
120 referenceMap.insert(i.key(), i.value()->getState());
121 }
122
123 for (auto i : uuidToNodeMap)
124 {
125 i->getState()->addReferences(referenceMap);
126 }
127}
128
129void
131 std::filesystem::path parentPath,
132 QList<statechartmodel::StatePtr>& allTheStates)
133{
134 std::filesystem::path nodePath = node->getBoostPath(parentPath);
135
136 if (node->getNodeType() == StateTreeNode::State)
137 {
138 try
139 {
141 QString::fromUtf8(nodePath.string().c_str()));
142 std::shared_ptr<XmlReader> reader(new XmlReader(iceCommunicator, variantInfo));
143 reader->parseXml(xml);
144 statechartmodel::StatePtr state = reader->getLoadedState();
145 state->setEditable(node->getGroup()->getWriteAccess() == StatechartGroup::eWritable);
146 setNodeState(node, state);
147 uuidToNodeMap.insert(state->getUUID(), node);
148 allTheStates.append(state);
149 }
151 {
152 ARMARX_ERROR_S << ex.what();
153 }
154 }
155 else if (node->getNodeType() == StateTreeNode::Folder)
156 {
157 for (int i = 0; i < node->getChildren().count(); i++)
158 {
159 loadNode(node->getChildren().at(i), nodePath, allTheStates);
160 }
161 }
162}
163
165StateTreeModel::loadGroup(QString groupDefinitionFile, StateTreeNodePtr rootNode)
166{
167 StatechartGroupPtr group = GuiStatechartGroupXmlReader::ReadXml(groupDefinitionFile, rootNode);
168
169 if (groupExists(group->getBoostGroupPath()))
170 {
171 return StatechartGroupPtr();
172 }
173 group->getPackageName();
174 loadVariantInfos(group->getPackageName().toStdString());
175 groups.append(group);
176 return group;
177}
178
179void
181{
182 groups.clear();
183 uuidToNodeMap.clear();
184}
185
186void
188{
189 groups.append(group);
190}
191
192void
194{
195 if (node->getNodeType() == StateTreeNode::State)
196 {
197 uuidToNodeMap.insert(node->getState()->getUUID(), node);
198 }
199}
200
201void
203{
204 if (node->getNodeType() == StateTreeNode::State && node->getState())
205 {
206 uuidToNodeMap.remove(node->getState()->getUUID());
207 }
208}
209
210void
211StateTreeModel::saveAll(QPointer<QProgressDialog> progressDialog)
212{
213 if (progressDialog)
214 {
215 progressDialog->setMinimum(0);
216 progressDialog->setMaximum(groups.count());
217 progressDialog->setLabelText("Saving statechart groups");
218 }
219 auto startTime = IceUtil::Time::now();
220#pragma omp parallel for schedule(static, 1)
221 for (int i = 0; i < groups.count(); i++)
222 {
223 StatechartGroupPtr group = groups.at(i);
224 if (group->getWriteAccess() == StatechartGroup::eReadOnly)
225 {
226 continue;
227 }
228 std::filesystem::create_directories(group->getBoostDefinitionFilePath().parent_path());
229 GroupXmlWriter::WriteXml(group, group->getDefinitionFilePath(), true);
230
231 for (int j = 0; j < group->getRootNode()->getChildren().count(); j++)
232 {
233 saveNode(group->getRootNode()->getChildren().at(j), group->getBoostGroupPath());
234 }
235 if (omp_get_thread_num() == 0)
236 {
237 if (progressDialog && (IceUtil::Time::now() - startTime).toMilliSeconds() > 1000)
238 {
239 progressDialog->setValue(i + 1);
240 // QMetaObject::invokeMethod(progressDialog, "setValue", Q_ARG(int, (i + 1)));
241 }
242 }
243 }
244}
245
246void
247StateTreeModel::saveNode(StateTreeNodePtr node, std::filesystem::path parentPath)
248{
249 std::filesystem::path nodePath = node->getBoostPath(parentPath);
250
251 if (node->getGroup()->getWriteAccess() == StatechartGroup::eReadOnly)
252 {
253 return;
254 }
255
256 if (node->getNodeType() == StateTreeNode::State)
257 {
258 try
259 {
260 if (node->getState())
261 {
262 XmlWriter writer(variantInfo);
263 writer.serialize(node->getState(), uuidToNodeMap);
264 //GroupXmlWriter::WriteFileContents(QString::fromUtf8(nodePath.string().c_str()), writer.getXmlString(true));
266 nodePath.string(), writer.getXmlString(true).toUtf8().data()))
267 {
268 ARMARX_INFO_S << "Writing new state definition to " << nodePath.string();
269 }
270 }
271 }
273 {
274 ARMARX_ERROR_S << ex.what();
275 }
276 catch (std::exception& e)
277 {
278 QMetaObject::invokeMethod(
279 this,
280 "showWarning",
281 Q_ARG(QString, "Saving state failed!"),
282 Q_ARG(QString,
283 QString::fromStdString(std::string(e.what())).split("Backtrace:").first()));
284 }
285 }
286 else if (node->getNodeType() == StateTreeNode::Folder)
287 {
288
289 std::filesystem::create_directory(nodePath);
290
291 for (int i = 0; i < node->getChildren().count(); i++)
292 {
293 saveNode(node->getChildren().at(i), nodePath);
294 }
295 }
296}
297
298void
300{
301 QString doxString = "/**\n";
302 doxString += "@defgroup " + group->getPackageName() + "-" + group->getName() + " " +
303 group->getName() + "";
304 doxString += "\n@ingroup Statecharts\n";
305 doxString += group->getDescription();
306 doxString += "@defgroup " + group->getPackageName() + "-" + group->getName() + "-Substates " +
307 group->getName() + " Substates\n";
308 doxString += "@ingroup " + group->getPackageName() + "-" + group->getName();
309 doxString += "\n*/";
310
311 // GroupXmlWriter::WriteFileContents(doxyGroupPath, doxString);
312}
313
315StateTreeModel::getPackageFinder(const QString& packageName)
316{
317 std::unique_lock lock(findersMutex);
318 auto it = finders.find(packageName);
319 if (it == finders.end())
320 {
321 finders.insert(std::make_pair(packageName, CMakePackageFinder(packageName.toStdString())));
322 return finders.at(packageName);
323 }
324 else
325 {
326 return it->second;
327 }
328}
329
330void
331StateTreeModel::loadVariantInfos(const std::string& packageName)
332{
333 //ARMARX_INFO << "loadVariantInfos: " << packageName;
334 auto finder = getPackageFinder(QString::fromStdString(packageName));
335 bool loaded = variantInfo->isPackageLoaded(packageName);
336 if (!finder.packageFound())
337 {
338 if (!!loaded)
339 {
340 ARMARX_WARNING_S << "Could not find package " << packageName
341 << " - generated code might be incomplete";
342 }
343 }
344 else
345 {
346 if (!loaded)
347 {
348 ARMARX_INFO_S << "Loading variant info for " << packageName << " and its dependencies";
350 packageName, finder.getConfigDir(), false, variantInfo);
351 }
352 auto contains =
353 [](const std::map<VariantTypeId, std::string>& map, const std::string& value)
354 {
355 for (const auto& v : map)
356 {
357 if (v.second == value)
358 {
359 return true;
360 }
361 }
362 return false;
363 };
364
365
366 for (VariantInfo::LibEntryPtr lib : variantInfo->getLibs())
367 {
368 if (lib->getPackageName() != packageName)
369 {
370 continue;
371 }
372 for (VariantInfo::VariantEntryPtr var : lib->getVariants())
373 {
374
375 if (!contains(Variant::getTypes(), var->getBaseTypeName()))
376 {
377 //ARMARX_IMPORTANT << VAROUT(Variant::getTypes());
378 //ARMARX_INFO << "loading lib for " << var->getBaseTypeName();
380 variantInfo->loadLibraryOfVariant(var->getBaseTypeName());
381 ARMARX_CHECK_EXPRESSION(lib) << var->getBaseTypeName();
382 lib->setUnloadOnDestruct(false);
383
385
386 Variant::addTypeName(var->getBaseTypeName());
387 // ARMARX_IMPORTANT << VAROUT(Variant::getTypes());
388 if (iceCommunicator->getValueFactoryManager()->find(var->getBaseTypeName()))
389 {
390 ARMARX_INFO << "Loaded variant " << var->getBaseTypeName();
391 }
392 else
393 {
394 ARMARX_WARNING << "variant " << var->getBaseTypeName()
395 << " could not be loaded. Adding Variant TypeName only.";
396 }
397 }
398 }
399 }
400
401 for (auto& dep : finder.getDependencies())
402 {
403 loadVariantInfos(dep);
404 }
405 }
406}
407
408void
409StateTreeModel::generateAllBaseClasses(QPointer<QProgressDialog> progressDialog)
410{
411 if (progressDialog)
412 {
413 progressDialog->setMinimum(0);
414 progressDialog->setMaximum(groups.count());
415 progressDialog->setLabelText("Generating code for statechart groups");
416 }
417 auto startTime = IceUtil::Time::now();
418#pragma omp parallel for schedule(static, 1)
419 for (int i = 0; i < groups.size(); ++i)
420 // for (const StatechartGroupPtr& group : groups)
421 {
422 const StatechartGroupPtr& group = groups.at(i);
423 generateBaseClasses(group);
424 if (omp_get_thread_num() == 0)
425 {
426 if (progressDialog && (IceUtil::Time::now() - startTime).toMilliSeconds() > 1000)
427 {
428 progressDialog->setValue(i + 1);
429 // QMetaObject::invokeMethod(progressDialog, "setValue", Q_ARG(int, (i + 1)));
430 }
431 }
432 else
433 {
434 if (progressDialog && (IceUtil::Time::now() - startTime).toMilliSeconds() > 1000)
435 {
436 QMetaObject::invokeMethod(progressDialog, "setValue", Q_ARG(int, (i + 1)));
437 }
438 }
439 }
440}
441
442std::set<std::string>
443StateTreeModel::getVariantOfStatesWithNoCpp(const StatechartGroupPtr& group)
444{
445 std::set<std::string> variantTypes;
446 std::set<std::string> alreadyLinkedTypes;
447 for (StateTreeNodePtr& stateNode : group->getAllNodes())
448 {
449 std::set<std::string>* currentTypeSet = &variantTypes;
450
451 if (stateNode->checkCppExists())
452 {
453 // only need if no cpp exists
454 currentTypeSet = &alreadyLinkedTypes;
455 }
456 auto state = stateNode->getState();
457 if (!state)
458 {
459 continue;
460 }
461 for (auto param : state->getInputAndLocalParameters())
462 {
463 QString type = param->type;
464 currentTypeSet->insert(type.toStdString());
465 }
466 for (auto param : state->getOutputParameters())
467 {
468 QString type = param->type;
469 currentTypeSet->insert(type.toStdString());
470 }
471 }
472
473
474 std::set<std::string> resultingTypes;
475 std::set_difference(variantTypes.begin(),
476 variantTypes.end(),
477 alreadyLinkedTypes.begin(),
478 alreadyLinkedTypes.end(),
479 std::inserter(resultingTypes, resultingTypes.end()));
480
481 std::set<std::string> innerVariantTypes;
482 for (auto& type : resultingTypes)
483 {
484 auto containerType = VariantContainerType::FromString(type);
485 while (containerType->subType)
486 {
487 containerType = containerType->subType;
488 }
489 if (!variantInfo->isBasic(containerType->typeId))
490 {
491 innerVariantTypes.insert(containerType->typeId);
492 }
493 }
494
495 return innerVariantTypes;
496}
497
498void
500{
501 /*std::filesystem::create_directories(group->getBoostDefinitionFilePath().parent_path());
502 std::vector<std::string> namespaces;
503 namespaces.push_back("armarx");
504 namespaces.push_back(group->getName().toUtf8().data());*/
505 auto checkPackage = [&](const CMakePackageFinder& finder)
506 {
507 if (!finder.packageFound())
508 {
509 QMetaObject::invokeMethod(this,
510 "showWarning",
511 Q_ARG(QString, "State Generation Error"),
512 Q_ARG(QString,
513 "Could not find the package '" +
514 QString::fromStdString(finder.getName()) +
515 "' - Did you run cmake for that package already? "
516 "Skipping state generation of stategroup " +
517 group->getName()));
518 return false;
519 }
520 else
521 {
522 return true;
523 }
524 };
525
526
527 std::map<QString, CMakePackageFinder>::const_iterator it;
528 {
529 std::unique_lock lock(findersMutex);
530 it = finders.find(group->getPackageName());
531
532
533 if (it == finders.end())
534 {
535 CMakePackageFinder finder(group->getPackageName().toStdString());
536
537 if (!checkPackage(finder))
538 {
539 return;
540 }
541
542 it = finders.insert(std::make_pair(group->getPackageName(), finder)).first;
543 }
544 }
545
546 CMakePackageFinder packageFinder = it->second;
547
548 if (!checkPackage(packageFinder))
549 {
550 return;
551 }
552 else if (packageFinder.getBuildDir().empty())
553 {
554 ARMARX_WARNING_S << "Build dir for package '" << packageFinder.getName()
555 << "' is empty! Skipping generating files.";
556 return;
557 }
558
559
560 std::filesystem::path doxyFile = packageFinder.getBuildDir();
561
562 if (!doxyFile.string().empty())
563 {
564 doxyFile /= "doxygen";
565 }
566 else
567 {
568 doxyFile = ".";
569 }
570
571 doxyFile /= group->getName().toStdString() + ".dox";
572 generateGroupDocString(group, QString::fromStdString(doxyFile.string()));
573
574 std::set<std::string> proxies;
575 proxies.insert("ArmarXCoreInterfaces.systemObserver");
576 proxies.insert("ArmarXCoreInterfaces.conditionHandler");
577 for (QString p : group->getProxies())
578 {
579 proxies.insert(p.toUtf8().data());
580 }
581 Ice::StringSeq proxyVec(proxies.begin(), proxies.end());
582 if (group->contextGenerationEnabled())
583 {
584 std::set<std::string> innerVariantTypes = getVariantOfStatesWithNoCpp(group);
586 packageFinder.getBuildDir(),
587 group->getPackageName().toUtf8().data(),
588 group->getName().toUtf8().data(),
589 proxyVec,
590 variantInfo,
591 innerVariantTypes,
592 false);
593 //std::string cpp = XmlContextBaseClassGenerator::GenerateCpp(namespaces, proxies, group->getName().toUtf8().data(), variantInfo);
594 //writeIfChanged((group->getBoostGroupPath() / (std::string(group->getName().toUtf8().data()) + "StatechartContext.generated.h")).c_str(), cpp);
595 }
596
597 for (StateTreeNodePtr node : group->getRootNode()->getChildren())
598 {
599 generateBaseClass(node, packageFinder.getBuildDir(), variantInfo, proxyVec);
600 }
601}
602
603void
605 std::filesystem::path buildDir,
606 VariantInfoPtr variantInfo,
607 std::vector<std::string> proxies)
608{
609 //std::filesystem::path nodePath = node->getBoostPath(parentPath);
610 if (node->getNodeType() == StateTreeNode::State)
611 {
612 try
613 {
614 if (node->getState() && node->getCppExists())
615 {
616 XmlWriter writer(variantInfo);
617 writer.serialize(node->getState(), uuidToNodeMap);
618 std::string xml = writer.getXmlString(false).toUtf8().data();
620 node->getState()->getStateName().toUtf8().data(),
622 buildDir,
623 node->getGroup()->getPackageName().toUtf8().data(),
624 node->getGroup()->getName().toUtf8().data(),
625 proxies,
626 node->getGroup()->contextGenerationEnabled(),
627 variantInfo,
628 false);
629 //std::string cpp = XmlStateBaseClassGenerator::GenerateCpp(namespaces, RapidXmlReader::FromXmlString(xml), proxies, node->getGroup()->contextGenerationEnabled(), node->getGroup()->getName().toUtf8().data(), variantInfo);
630 //std::string targetPath(nodePath.replace_extension().string() + ".generated.h");
631 //writeIfChanged(targetPath, cpp);
632 }
633 }
635 {
636 ARMARX_ERROR_S << ex.what();
637 }
638 catch (std::exception& e)
639 {
640 QMessageBox::warning(
641 0,
642 "Saving state failed!",
643 QString::fromStdString(std::string(e.what())).split("Backtrace:").first());
644 }
645 }
646 else if (node->getNodeType() == StateTreeNode::Folder)
647 {
648 //std::filesystem::create_directory(nodePath);
649 for (StateTreeNodePtr child : node->getChildren())
650 {
651 generateBaseClass(child, buildDir, variantInfo, proxies);
652 }
653 }
654}
655
656void
657StateTreeModel::writeIfChanged(std::string targetPath, std::string contents)
658{
659 bool identical = false;
660
661 if (std::filesystem::exists(std::filesystem::path(targetPath)))
662 {
663 std::string currentContents = RapidXmlReader::ReadFileContents(targetPath);
664 identical = contents == currentContents;
665 }
666
667 if (!identical)
668 {
669 QString qtargetPath = QString::fromUtf8(targetPath.data());
670 //QMessageBox::information(NULL, "test", qtargetPath);
671 ARMARX_LOG_S << "Generated file " << targetPath;
672 GroupXmlWriter::WriteFileContents(qtargetPath, QString::fromUtf8(contents.data()));
673 }
674 else
675 {
676 ARMARX_LOG_S << "Skipping identical file " << targetPath;
677 //QMessageBox::information(NULL, "test", "current file and generated output are identical.");
678 }
679}
680
683{
684 return rootNode;
685}
686
687QList<StatechartGroupPtr>
689{
690 return QList<StatechartGroupPtr>(groups);
691}
692
694StateTreeModel::getGroupByName(const QString& groupName) const
695{
696 auto it = std::find_if(groups.constBegin(),
697 groups.constEnd(),
698 [&](const StatechartGroupPtr& g) { return g->getName() == groupName; });
699
700 if (it != groups.constEnd())
701 {
702 return *it;
703 }
704 else
705 {
706 return StatechartGroupPtr();
707 }
708}
709
712{
713 if (!state)
714 {
715 return StateTreeNodePtr();
716 }
717
718 return getNodeByUuid(state->getUUID());
719}
720
722StateTreeModel::getNodeByUuid(const QString& uuid) const
723{
724 QMap<QString, StateTreeNodePtr>::const_iterator it = uuidToNodeMap.find(uuid);
725
726 if (it != uuidToNodeMap.end())
727 {
728 return it.value();
729 }
730 else
731 {
732 return StateTreeNodePtr();
733 }
734}
735
736void
738{
739 node->state = state;
740 node->checkCppExists();
741 node->display = state->getStateName();
742 connect(state.get(),
744 SLOT(notifySubstateChanged(statechartmodel::StateInstancePtr,
746}
747
748QList<StateInstancePtr>
750{
751 QList<StateInstancePtr> instances;
752 QMapIterator<QString, StateTreeNodePtr> i(uuidToNodeMap);
753
754 while (i.hasNext())
755 {
756 i.next();
757 QMapIterator<QString, StateInstancePtr> itSubstate = i.value()->getState()->getSubstates();
758
759 while (itSubstate.hasNext())
760 {
761 itSubstate.next();
762 statechartmodel::StatePtr state = itSubstate.value()->getStateClass();
763
764 if (state && node->getState() == state)
765 {
766 instances.append(itSubstate.value());
767 }
768 }
769 }
770
771 return instances;
772}
773
774bool
776{
777 return groupExists(group->getBoostGroupPath());
778}
779
780bool
781StateTreeModel::groupExists(std::filesystem::path groupPath)
782{
783 foreach (StatechartGroupPtr g, groups)
784 {
785 if (g->getBoostGroupPath() == groupPath)
786 {
787 return true;
788 }
789 }
790 return false;
791}
792
793void
794StateTreeModel::notifySubstateChanged(StateInstancePtr substate, SignalType signalType)
795{
796 if (signalType == eAdded || signalType == eRemoved)
797 {
799 }
800}
801
802void
803StateTreeModel::showWarning(QString title, QString message)
804{
805 QMessageBox::warning(0, title, message);
806}
807
808/*
809StatechartGroupTreeNodePtr StateTreeModel::createNewState(QString name, StatechartGroupTreeNodePtr parent)
810{
811 statechartmodel::StatePtr state(new State());
812 state->setStateName(name);
813 StatechartGroupTreeNodePtr node(new StatechartGroupTreeNode(name, name + ".xml", StatechartGroupTreeNode::State, parent, parent->getGroup()));
814 node->setState(state);
815 parent->appendChild(node);
816 uuidToNodeMap.insert(state->getUUID(), node);
817 return node;
818}*/
static void RegisterKnownObjectFactoriesWithIce(const Ice::CommunicatorPtr &ic)
Registers all object factories that are known with Ice.
The CMakePackageFinder class provides an interface to the CMake Package finder capabilities.
std::string getName() const
Returns the name of the given package.
std::string getBuildDir() const
static void WriteFileContents(QString path, QString contents)
static void WriteXml(StatechartGroupPtr group, QString path, bool indent=true)
static QString ReadFileContents(QString path)
static StatechartGroupPtr ReadXml(QString groupDefinitionFile, StateTreeNodePtr virtualRoot)
static std::string ReadFileContents(const std::string &path)
static RapidXmlReaderPtr FromXmlString(const std::string &xml)
void loadVariantInfos(const std::string &packageName)
QList< StatechartGroupPtr > getGroups() const
void setNodeState(StateTreeNodePtr node, statechartmodel::StatePtr state)
void loadGroupStates(StatechartGroupPtr group)
bool groupExists(StatechartGroupPtr group)
void generateBaseClasses(const StatechartGroupPtr &group)
QList< statechartmodel::StateInstancePtr > findStateUsages(StateTreeNodePtr node)
void generateAllBaseClasses(QPointer< QProgressDialog > progressDialog=NULL)
void loadNode(StateTreeNodePtr node, std::filesystem::path parentPath, QList< statechartmodel::StatePtr > &allTheReaders)
StateTreeModel(Ice::CommunicatorPtr ic, VariantInfoPtr variantInfo)
void addGroup(StatechartGroupPtr group)
StatechartGroupPtr loadGroup(QString groupDefinitionFile, StateTreeNodePtr rootNode)
void writeIfChanged(std::string targetPath, std::string contents)
StatechartGroupPtr getGroupByName(const QString &groupName) const
StateTreeNodePtr getNodeByUuid(const QString &uuid) const
void generateGroupDocString(StatechartGroupPtr group, QString doxyGroupPath)
const CMakePackageFinder & getPackageFinder(const QString &packageName)
void notifyNewStateTreeNode(StateTreeNodePtr node)
void generateBaseClass(StateTreeNodePtr node, std::filesystem::path buildDir, VariantInfoPtr variantInfo, std::vector< std::string > proxies)
void saveAll(QPointer< QProgressDialog > progressDialog=NULL)
StateTreeNodePtr getNodeByState(statechartmodel::StatePtr state) const
StateTreeNodePtr getRootNode() const
void notifyDeleteStateTreeNode(StateTreeNodePtr node)
void saveNode(StateTreeNodePtr node, std::filesystem::path parentPath)
void annotateStateRerefences(const QList< statechartmodel::StatePtr > &statesToAnnotate)
static bool generateStateFile(const std::string &statechartGroupXmlFilePath, const std::string &statePath, const std::string &packagePath, const std::optional< std::string > &packageIncludePath=std::nullopt)
static bool generateStatechartContextFile(const std::string &statechartGroupXmlFilePath, const std::string &packagePath, const std::optional< std::string > &packageIncludePath=std::nullopt)
static bool writeFileContentsIfChanged(const std::string &path, const std::string &contents)
static ContainerTypePtr FromString(const std::string &typeStr)
static VariantInfoPtr ReadInfoFilesRecursive(const std::string &rootPackageName, const std::string &rootPackagePath, bool showErrors, VariantInfoPtr variantInfo=VariantInfoPtr())
std::shared_ptr< LibEntry > LibEntryPtr
std::shared_ptr< VariantEntry > VariantEntryPtr
Definition VariantInfo.h:48
static const std::map< VariantTypeId, std::string > & getTypes()
Returns the mapping of currently registered types.
Definition Variant.cpp:863
static VariantTypeId addTypeName(const std::string &typeName)
Register a new type for the use in a Variant.
Definition Variant.cpp:869
XML reader class used to build State objects from XML representations.
Definition XmlReader.h:39
XML writer class used to build XML representations of State objects.
Definition XmlWriter.h:62
QString getXmlString(bool indent=true) const
Builds the XML document for the state object that has been handled by serialize() before.
Definition XmlWriter.cpp:90
void serialize(armarx::statechartmodel::StateCPtr state, const QMap< QString, StateTreeNodePtr > &uuidToNodeMap=QMap< QString, StateTreeNodePtr >())
Builds XML data structures for serialization of the given state object.
Definition XmlWriter.cpp:46
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:181
#define ARMARX_ERROR_S
The logging level for unexpected behaviour, that must be fixed.
Definition Logging.h:216
#define ARMARX_INFO_S
Definition Logging.h:202
#define ARMARX_LOG_S
This macro creates a new temporary instance which can then be used to log data using the << operator.
Definition Logging.h:145
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
Definition Logging.h:193
#define ARMARX_WARNING_S
The logging level for unexpected behaviour, but not a serious problem.
Definition Logging.h:213
::IceInternal::Handle<::Ice::Communicator > CommunicatorPtr
Definition IceManager.h:49
std::shared_ptr< State > StatePtr
Definition State.h:48
std::shared_ptr< StateInstance > StateInstancePtr
SignalType
The SignalType enum.
Definition SignalType.h:34
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::shared_ptr< StatechartGroup > StatechartGroupPtr
std::shared_ptr< VariantInfo > VariantInfoPtr
Definition VariantInfo.h:39
std::shared_ptr< StateTreeNode > StateTreeNodePtr
std::shared_ptr< DynamicLibrary > DynamicLibraryPtr