StateTreeModel.h
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#pragma once
25
26#include <mutex>
27
28#include <QMap>
29#include <QProgressDialog>
30
31// Qt headers must come before <filesystem>
32// https://stackoverflow.com/questions/69407237/qt-moc-errorusr-include-c-10-bits-fs-fwd-39-parse-error-at-std
33#include <filesystem>
34
37
38#include "../io/XmlReader.h"
39#include "StateTreeNode.h"
40#include "StatechartGroup.h"
41
42namespace armarx
43{
44
45 class StateTreeModel;
46 using StateTreeModelPtr = std::shared_ptr<StateTreeModel>;
47
48 class StateTreeModel : public QObject
49 {
50 Q_OBJECT
51
52 public:
54
55 void loadAllStates();
57 void annotateStateRerefences(const QList<statechartmodel::StatePtr>& statesToAnnotate);
59
60 void loadNode(StateTreeNodePtr node,
61 std::filesystem::path parentPath,
62 QList<statechartmodel::StatePtr>& allTheReaders);
63 StatechartGroupPtr loadGroup(QString groupDefinitionFile, StateTreeNodePtr rootNode);
64 void clear();
65 void addGroup(StatechartGroupPtr group);
66
67 //StatechartGroupTreeNodePtr createNewState(QString name, StatechartGroupTreeNodePtr parent);
70
71 void saveAll(QPointer<QProgressDialog> progressDialog = NULL);
72 void saveNode(StateTreeNodePtr node, std::filesystem::path parentPath);
73 void generateAllBaseClasses(QPointer<QProgressDialog> progressDialog = NULL);
74 void generateBaseClasses(const StatechartGroupPtr& group);
76 std::filesystem::path buildDir,
77 VariantInfoPtr variantInfo,
78 std::vector<std::string> proxies);
79 void writeIfChanged(std::string targetPath, std::string contents);
80
82
83 QList<StatechartGroupPtr> getGroups() const;
84 StatechartGroupPtr getGroupByName(const QString& groupName) const;
86 StateTreeNodePtr getNodeByUuid(const QString& uuid) const;
87
89 QList<statechartmodel::StateInstancePtr> findStateUsages(StateTreeNodePtr node);
91 bool groupExists(std::filesystem::path groupPath);
92
93 void generateGroupDocString(StatechartGroupPtr group, QString doxyGroupPath);
94 const CMakePackageFinder& getPackageFinder(const QString& packageName);
95 void loadVariantInfos(const std::string& packageName);
96 private slots:
97 void notifySubstateChanged(statechartmodel::StateInstancePtr substate,
99 void showWarning(QString title, QString message);
100
101 signals:
103
104 private:
105 QMap<QString, StateTreeNodePtr> uuidToNodeMap;
106 QList<StatechartGroupPtr> groups;
107 Ice::CommunicatorPtr iceCommunicator;
108 StateTreeNodePtr rootNode;
109 VariantInfoPtr variantInfo;
110 std::mutex findersMutex;
111 std::map<QString, CMakePackageFinder> finders;
112 std::set<std::string> getVariantOfStatesWithNoCpp(const StatechartGroupPtr& group);
113 };
114} // namespace armarx
The CMakePackageFinder class provides an interface to the CMake Package finder capabilities.
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)
::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< StateTreeModel > StateTreeModelPtr
std::shared_ptr< StateTreeNode > StateTreeNodePtr