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 
31 #include "../../StatechartViewerPlugin/model/State.h"
32 #include "StatechartGroup.h"
33 #include "StatechartGroupDefs.h"
34 
35 namespace 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:
45  enum NodeType
46  {
50  };
51  enum class Path
52  {
53  Absolute,
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
armarx::StateTreeNode::getAllStatesRecursively
QVector< statechartmodel::StatePtr > getAllStatesRecursively(bool localOnly) const
Definition: StateTreeNode.cpp:363
armarx::StateTreeNode::isFolderOrGroup
bool isFolderOrGroup() const
Definition: StateTreeNode.cpp:292
armarx::StateTreeNode
Definition: StateTreeNode.h:40
StatechartGroupDefs.h
armarx::StateTreeNode::row
int row() const
Definition: StateTreeNode.cpp:128
armarx::StateTreeNode::isState
bool isState() const
Definition: StateTreeNode.cpp:286
armarx::StateTreeNodePtr
std::shared_ptr< StateTreeNode > StateTreeNodePtr
Definition: StatechartGroupDefs.h:31
armarx::StateTreeNode::getBoostXmlFilePath
std::filesystem::path getBoostXmlFilePath(Path pathType=Path::Absolute) const
Definition: StateTreeNode.cpp:183
armarx::StateTreeNode::columnCount
int columnCount() const
Definition: StateTreeNode.cpp:116
armarx::StateTreeNode::isPublic
bool isPublic()
Definition: StateTreeNode.cpp:430
armarx::StateTreeNode::findNodeByStateName
StateTreeNodePtr findNodeByStateName(QString name)
Definition: StateTreeNode.cpp:324
armarx::StateTreeNode::getGroup
StatechartGroupPtr getGroup()
Definition: StateTreeNode.cpp:159
armarx::StateTreeNode::Group
@ Group
Definition: StateTreeNode.h:47
armarx::StateTreeNode::getBasename
QString getBasename() const
Definition: StateTreeNode.cpp:171
armarx::StateTreeNode::getBoostPathRelativeToGroup
std::filesystem::path getBoostPathRelativeToGroup() const
Definition: StateTreeNode.cpp:265
armarx::StateTreeNode::checkCppExists
bool checkCppExists()
Definition: StateTreeNode.cpp:247
armarx::StateTreeNode::appendChild
void appendChild(StateTreeNodePtr child)
Definition: StateTreeNode.cpp:53
armarx::StateTreeNode::getBoostPath
std::filesystem::path getBoostPath(std::filesystem::path parentPath) const
Definition: StateTreeNode.cpp:259
armarx::StateTreeNode::sortChildren
void sortChildren()
Definition: StateTreeNode.cpp:92
armarx::StateTreeNode::getAbsoluteBoostPath
std::filesystem::path getAbsoluteBoostPath() const
Definition: StateTreeNode.cpp:177
armarx::StateTreeNode::Path::RelativeToGroup
@ RelativeToGroup
armarx::StateTreeNode::getState
armarx::statechartmodel::StatePtr getState() const
Definition: StateTreeNode.cpp:280
armarx::ctrlutil::a
double a(double t, double a0, double j)
Definition: CtrlUtil.h:45
StatechartGroup.h
armarx::StateTreeNode::~StateTreeNode
~StateTreeNode()
Definition: StateTreeNode.cpp:47
armarx::StateTreeModel
Definition: StateTreeModel.h:48
armarx::StateTreeNode::getBoostHFilePath
std::filesystem::path getBoostHFilePath(Path pathType=Path::Absolute) const
Definition: StateTreeNode.cpp:208
armarx::StateTreeNode::getClosestParentFolderOrGroupNode
StateTreeNodePtr getClosestParentFolderOrGroupNode()
Definition: StateTreeNode.cpp:310
armarx::StateTreeNode::getBoostGeneratedHFilePath
std::filesystem::path getBoostGeneratedHFilePath(Path pathType=Path::Absolute) const
Definition: StateTreeNode.cpp:222
armarx::StateTreeNode::setPublic
void setPublic(bool isPublic)
Definition: StateTreeNode.cpp:436
armarx::StateTreeNode::child
StateTreeNodePtr child(int row)
Definition: StateTreeNode.cpp:104
armarx::State
Definition: State.h:53
armarx::StateTreeNode::CheckNodeName
static bool CheckNodeName(QString name)
Definition: StateTreeNode.cpp:415
armarx::StateTreeNode::getCppExists
bool getCppExists() const
Definition: StateTreeNode.cpp:236
armarx::StateTreeNode::removeChild
void removeChild(StateTreeNodePtr child)
Definition: StateTreeNode.cpp:98
armarx::StateTreeNode::isGroup
bool isGroup() const
Definition: StateTreeNode.cpp:298
armarx::StatechartGroupPtr
std::shared_ptr< StatechartGroup > StatechartGroupPtr
Definition: StatechartGroupDefs.h:34
armarx::StateTreeNode::StateTreeNode
StateTreeNode(QString display, QString basename, NodeType nodeType, StateTreeNodePtr parentNode, StatechartGroupPtr parentGroup, bool stateIsPublic)
Definition: StateTreeNode.cpp:30
armarx::StateTreeNode::getAllSubNodesRecursively
QVector< StateTreeNodePtr > getAllSubNodesRecursively() const
Definition: StateTreeNode.cpp:345
armarx::StateTreeNode::getChildren
QList< StateTreeNodePtr > getChildren() const
Definition: StateTreeNode.cpp:424
armarx::StateTreeNode::getDisplay
QString getDisplay() const
Definition: StateTreeNode.cpp:122
armarx::StateTreeNode::NodeType
NodeType
Definition: StateTreeNode.h:45
armarx::StateTreeNode::getParent
StateTreeNodePtr getParent() const
Definition: StateTreeNode.cpp:153
armarx::statechartmodel::StatePtr
std::shared_ptr< State > StatePtr
Definition: State.h:48
armarx::StateTreeNode::Folder
@ Folder
Definition: StateTreeNode.h:48
armarx::StateTreeNode::childCount
int childCount() const
Definition: StateTreeNode.cpp:110
armarx::StateTreeNode::Path
Path
Definition: StateTreeNode.h:51
armarx::StateTreeNode::getNodeType
NodeType getNodeType()
Definition: StateTreeNode.cpp:165
armarx::StateTreeNode::getNestingLevelRelativeToGroup
int getNestingLevelRelativeToGroup()
Definition: StateTreeNode.cpp:404
armarx::StateTreeNode::Path::Absolute
@ Absolute
armarx::StateTreeNode::getBoostCppFilePath
std::filesystem::path getBoostCppFilePath(Path pathType=Path::Absolute) const
Definition: StateTreeNode.cpp:194
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::StateTreeNode::isFolder
bool isFolder() const
Definition: StateTreeNode.cpp:304