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 "StateTreeNode.h"
27 #include "StatechartGroup.h"
28 
29 #include "../io/XmlReader.h"
30 
33 
34 #include <QMap>
35 #include <QProgressDialog>
36 
37 #include <filesystem>
38 #include <mutex>
39 
40 namespace armarx
41 {
42 
43  class StateTreeModel;
44  using StateTreeModelPtr = std::shared_ptr<StateTreeModel>;
45 
46  class StateTreeModel : public QObject
47  {
48  Q_OBJECT
49 
50  public:
52 
53  void loadAllStates();
55  void annotateStateRerefences(const QList<statechartmodel::StatePtr>& statesToAnnotate);
57 
58  void loadNode(StateTreeNodePtr node, std::filesystem::path parentPath, QList<statechartmodel::StatePtr>& allTheReaders);
59  StatechartGroupPtr loadGroup(QString groupDefinitionFile, StateTreeNodePtr rootNode);
60  void clear();
61  void addGroup(StatechartGroupPtr group);
62 
63  //StatechartGroupTreeNodePtr createNewState(QString name, StatechartGroupTreeNodePtr parent);
66 
67  void saveAll(QPointer<QProgressDialog> progressDialog = NULL);
68  void saveNode(StateTreeNodePtr node, std::filesystem::path parentPath);
69  void generateAllBaseClasses(QPointer<QProgressDialog> progressDialog = NULL);
70  void generateBaseClasses(const StatechartGroupPtr& group);
71  void generateBaseClass(StateTreeNodePtr node, std::filesystem::path buildDir, VariantInfoPtr variantInfo, std::vector<std::string> proxies);
72  void writeIfChanged(std::string targetPath, std::string contents);
73 
75 
76  QList<StatechartGroupPtr> getGroups() const;
77  StatechartGroupPtr getGroupByName(const QString& groupName) const;
79  StateTreeNodePtr getNodeByUuid(const QString& uuid) const;
80 
82  QList<statechartmodel::StateInstancePtr> findStateUsages(StateTreeNodePtr node);
83  bool groupExists(StatechartGroupPtr group);
84  bool groupExists(std::filesystem::path groupPath);
85 
86  void generateGroupDocString(StatechartGroupPtr group, QString doxyGroupPath);
87  const CMakePackageFinder& getPackageFinder(const QString& packageName);
88  void loadVariantInfos(const std::string& packageName);
89  private slots:
90  void notifySubstateChanged(statechartmodel::StateInstancePtr substate, statechartmodel::SignalType signalType);
91  void showWarning(QString title, QString message);
92 
93  signals:
94  void stateAddedOrRemoved();
95 
96  private:
97  QMap<QString, StateTreeNodePtr> uuidToNodeMap;
98  QList<StatechartGroupPtr> groups;
99  Ice::CommunicatorPtr iceCommunicator;
100  StateTreeNodePtr rootNode;
101  VariantInfoPtr variantInfo;
102  std::mutex findersMutex;
103  std::map<QString, CMakePackageFinder> finders;
104  std::set<std::string> getVariantOfStatesWithNoCpp(const StatechartGroupPtr& group);
105  };
106 }
107 
armarx::StateTreeModel::notifyNewStateTreeNode
void notifyNewStateTreeNode(StateTreeNodePtr node)
Definition: StateTreeModel.cpp:177
armarx::StateTreeModel::getNodeByState
StateTreeNodePtr getNodeByState(statechartmodel::StatePtr state) const
Definition: StateTreeModel.cpp:645
armarx::StateTreeModelPtr
std::shared_ptr< StateTreeModel > StateTreeModelPtr
Definition: StateTreeModel.h:44
cyberglove_with_calib_22dof.ic
ic
Definition: cyberglove_with_calib_22dof.py:22
armarx::StateTreeNodePtr
std::shared_ptr< StateTreeNode > StateTreeNodePtr
Definition: StatechartGroupDefs.h:31
armarx::StateTreeModel::loadGroupStates
void loadGroupStates(StatechartGroupPtr group)
Definition: StateTreeModel.cpp:74
armarx::StateTreeModel::addGroup
void addGroup(StatechartGroupPtr group)
Definition: StateTreeModel.cpp:172
armarx::StateTreeModel::StateTreeModel
StateTreeModel(Ice::CommunicatorPtr ic, VariantInfoPtr variantInfo)
Definition: StateTreeModel.cpp:47
armarx::StateTreeModel::generateAllBaseClasses
void generateAllBaseClasses(QPointer< QProgressDialog > progressDialog=NULL)
Definition: StateTreeModel.cpp:375
armarx::CMakePackageFinder
The CMakePackageFinder class provides an interface to the CMake Package finder capabilities.
Definition: CMakePackageFinder.h:53
message
message(STATUS "Boost-Library-Dir: " "${Boost_LIBRARY_DIRS}") message(STATUS "Boost-LIBRARIES
Definition: CMakeLists.txt:8
armarx::StateTreeModel::clear
void clear()
Definition: StateTreeModel.cpp:166
armarx::StateTreeModel::saveAll
void saveAll(QPointer< QProgressDialog > progressDialog=NULL)
Definition: StateTreeModel.cpp:193
armarx::statechartmodel::StateInstancePtr
std::shared_ptr< StateInstance > StateInstancePtr
Definition: StateInstance.h:138
armarx::StateTreeModel::annotateStateRerefences
void annotateStateRerefences(const QList< statechartmodel::StatePtr > &statesToAnnotate)
Definition: StateTreeModel.cpp:86
armarx::StateTreeModel::annotateAllStateRerefences
void annotateAllStateRerefences()
Definition: StateTreeModel.cpp:103
IceInternal::Handle< ::Ice::Communicator >
armarx::StateTreeModel::saveNode
void saveNode(StateTreeNodePtr node, std::filesystem::path parentPath)
Definition: StateTreeModel.cpp:228
armarx::StateTreeModel::groupExists
bool groupExists(StatechartGroupPtr group)
Definition: StateTreeModel.cpp:702
armarx::StateTreeModel::loadNode
void loadNode(StateTreeNodePtr node, std::filesystem::path parentPath, QList< statechartmodel::StatePtr > &allTheReaders)
Definition: StateTreeModel.cpp:120
armarx::StateTreeModel::getGroups
QList< StatechartGroupPtr > getGroups() const
Definition: StateTreeModel.cpp:623
StatechartGroup.h
armarx::StateTreeModel::getNodeByUuid
StateTreeNodePtr getNodeByUuid(const QString &uuid) const
Definition: StateTreeModel.cpp:655
armarx::StateTreeModel
Definition: StateTreeModel.h:46
armarx::StateTreeModel::generateGroupDocString
void generateGroupDocString(StatechartGroupPtr group, QString doxyGroupPath)
Definition: StateTreeModel.cpp:274
armarx::StateTreeModel::generateBaseClasses
void generateBaseClasses(const StatechartGroupPtr &group)
Definition: StateTreeModel.cpp:461
armarx::StatechartGroupPtr
std::shared_ptr< StatechartGroup > StatechartGroupPtr
Definition: StatechartGroupDefs.h:34
CMakePackageFinder.h
armarx::statechartmodel::SignalType
SignalType
The SignalType enum.
Definition: SignalType.h:33
armarx::StateTreeModel::loadAllStates
void loadAllStates()
Definition: StateTreeModel.cpp:56
armarx::StateTreeModel::getPackageFinder
const CMakePackageFinder & getPackageFinder(const QString &packageName)
Definition: StateTreeModel.cpp:287
armarx::StateTreeModel::setNodeState
void setNodeState(StateTreeNodePtr node, statechartmodel::StatePtr state)
Definition: StateTreeModel.cpp:669
armarx::StateTreeModel::loadGroup
StatechartGroupPtr loadGroup(QString groupDefinitionFile, StateTreeNodePtr rootNode)
Definition: StateTreeModel.cpp:152
armarx::VariantInfoPtr
std::shared_ptr< VariantInfo > VariantInfoPtr
Definition: VariantInfo.h:39
armarx::StateTreeModel::notifyDeleteStateTreeNode
void notifyDeleteStateTreeNode(StateTreeNodePtr node)
Definition: StateTreeModel.cpp:185
armarx::StateTreeModel::writeIfChanged
void writeIfChanged(std::string targetPath, std::string contents)
Definition: StateTreeModel.cpp:594
armarx::StateTreeModel::getGroupByName
StatechartGroupPtr getGroupByName(const QString &groupName) const
Definition: StateTreeModel.cpp:628
armarx::statechartmodel::StatePtr
std::shared_ptr< State > StatePtr
Definition: State.h:46
armarx::StateTreeModel::generateBaseClass
void generateBaseClass(StateTreeNodePtr node, std::filesystem::path buildDir, VariantInfoPtr variantInfo, std::vector< std::string > proxies)
Definition: StateTreeModel.cpp:556
armarx::StateTreeModel::loadVariantInfos
void loadVariantInfos(const std::string &packageName)
Definition: StateTreeModel.cpp:303
armarx::StateTreeModel::stateAddedOrRemoved
void stateAddedOrRemoved()
StateTreeNode.h
armarx::StateTreeModel::findStateUsages
QList< statechartmodel::StateInstancePtr > findStateUsages(StateTreeNodePtr node)
Definition: StateTreeModel.cpp:677
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::StateTreeModel::getRootNode
StateTreeNodePtr getRootNode() const
Definition: StateTreeModel.cpp:618
VariantInfo.h