StateTreeNode.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 <filesystem>
27#include <memory>
28
29#include <QVariant>
30
32#include "StatechartGroup.h"
33#include "StatechartGroupDefs.h"
34
35namespace armarx
36{
37
38 class StateTreeModel;
39
40 class StateTreeNode : public std::enable_shared_from_this<StateTreeNode>
41 {
42 friend class StateTreeModel;
43
44 public:
51 enum class Path
52 {
55 };
56
57 StateTreeNode(QString display,
58 QString basename,
59 NodeType nodeType,
60 StateTreeNodePtr parentNode,
61 StatechartGroupPtr parentGroup,
62 bool stateIsPublic);
64
66 void sortChildren();
68
70 int childCount() const;
71 int columnCount() const;
72 QString getDisplay() const;
73 int row() const;
76 QList<StateTreeNodePtr> getChildren() const;
77 bool isPublic();
78 void setPublic(bool isPublic);
79
81
82 QString getBasename() const;
83 std::filesystem::path getBoostPath(std::filesystem::path parentPath) const;
84 std::filesystem::path getBoostPathRelativeToGroup() const;
85 std::filesystem::path getAbsoluteBoostPath() const;
86 std::filesystem::path getBoostXmlFilePath(Path pathType = Path::Absolute) const;
87 std::filesystem::path getBoostCppFilePath(Path pathType = Path::Absolute) const;
88 std::filesystem::path getBoostHFilePath(Path pathType = Path::Absolute) const;
89 std::filesystem::path getBoostGeneratedHFilePath(Path pathType = Path::Absolute) const;
90 bool getCppExists() const;
91 bool checkCppExists();
92
94 //void setState(const armarx::statechartmodel::StatePtr &value);
95
96 bool isState() const;
97 bool isFolderOrGroup() const;
98 bool isGroup() const;
99 bool isFolder() const;
101
103 QVector<StateTreeNodePtr> getAllSubNodesRecursively() const;
104 QVector<statechartmodel::StatePtr> getAllStatesRecursively(bool localOnly) const;
105
107
108 static bool CheckNodeName(QString name);
109
110 private:
111 static int NodeTypeToSortIndex(NodeType nodeType);
112 static bool CompareChildren(const StateTreeNodePtr& a, const StateTreeNodePtr& b);
113 void GetAllSubstatesRecursively(const statechartmodel::StatePtr& state,
114 QVector<statechartmodel::StatePtr>& result,
115 bool localOnly) const;
116
117 QList<StateTreeNodePtr> children;
118 QList<QVariant> itemData;
119 std::weak_ptr<StateTreeNode> parentNode;
120 std::weak_ptr<StatechartGroup> parentGroup;
121 NodeType nodeType;
122 QString basename;
123 QString display;
125 bool stateIsPublic;
126 bool cppExists;
127 };
128
129} // namespace armarx
void appendChild(StateTreeNodePtr child)
std::filesystem::path getBoostHFilePath(Path pathType=Path::Absolute) const
QVector< statechartmodel::StatePtr > getAllStatesRecursively(bool localOnly) const
QVector< StateTreeNodePtr > getAllSubNodesRecursively() const
armarx::statechartmodel::StatePtr getState() const
std::filesystem::path getBoostPath(std::filesystem::path parentPath) const
void setPublic(bool isPublic)
std::filesystem::path getBoostGeneratedHFilePath(Path pathType=Path::Absolute) const
std::filesystem::path getAbsoluteBoostPath() const
StateTreeNodePtr child(int row)
friend class StateTreeModel
StatechartGroupPtr getGroup()
std::filesystem::path getBoostXmlFilePath(Path pathType=Path::Absolute) const
QList< StateTreeNodePtr > getChildren() const
QString getBasename() const
StateTreeNode(QString display, QString basename, NodeType nodeType, StateTreeNodePtr parentNode, StatechartGroupPtr parentGroup, bool stateIsPublic)
std::filesystem::path getBoostPathRelativeToGroup() const
static bool CheckNodeName(QString name)
void removeChild(StateTreeNodePtr child)
StateTreeNodePtr getParent() const
StateTreeNodePtr findNodeByStateName(QString name)
StateTreeNodePtr getClosestParentFolderOrGroupNode()
std::filesystem::path getBoostCppFilePath(Path pathType=Path::Absolute) const
QString getDisplay() const
std::shared_ptr< State > StatePtr
Definition State.h:48
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::shared_ptr< StatechartGroup > StatechartGroupPtr
std::shared_ptr< StateTreeNode > StateTreeNodePtr