26#include <boost/regex.hpp>
37 this->display = display;
38 this->basename = basename;
39 this->nodeType = nodeType;
40 this->parentNode = parentNode;
41 this->parentGroup = parentGroup;
42 this->stateIsPublic = stateIsPublic;
43 this->cppExists =
false;
55 children.append(
child);
59StateTreeNode::NodeTypeToSortIndex(NodeType nodeType)
80 int aTypeIndex = NodeTypeToSortIndex(
a->nodeType);
81 int bTypeIndex = NodeTypeToSortIndex(b->nodeType);
83 if (aTypeIndex != bTypeIndex)
85 return aTypeIndex < bTypeIndex;
88 return a->display.toLower().localeAwareCompare(b->display.toLower()) < 0;
94 qStableSort(children.begin(), children.end(), CompareChildren);
100 children.removeOne(
child);
106 return children.value(
row);
112 return children.count();
138 for (
int i = 0; i < parent->children.count(); i++)
140 if (parent->children.at(i).get() ==
this)
155 return parentNode.lock();
161 return parentGroup.lock();
187 return std::filesystem::path();
198 return std::filesystem::path();
201 std::string filename = std::string(state->getStateName().toUtf8().data()) +
".cpp";
204 return (path.remove_filename() / filename);
212 return std::filesystem::path();
215 std::string filename = std::string(state->getStateName().toUtf8().data()) +
".h";
218 return (path.remove_filename() / filename);
226 return std::filesystem::path();
229 std::string filename = std::string(state->getStateName().toUtf8().data()) +
".generated.h";
232 return (path.remove_filename() / filename);
261 return parentPath / basename.toUtf8().data();
267 std::filesystem::path result = basename.toUtf8().data();
270 while (p && !p->isGroup())
272 result = std::filesystem::path(p->getBasename().toUtf8().data()) / result;
288 return nodeType ==
State;
300 return nodeType ==
Group;
306 return nodeType ==
Folder;
316 node = node->getParent();
326 if (state && state->getStateName() == name)
328 return shared_from_this();
331 for (
int i = 0; i < children.count(); i++)
344QVector<StateTreeNodePtr>
347 QVector<StateTreeNodePtr> result;
351 result.push_back(node);
353 for (
const auto& n : node->getAllSubNodesRecursively())
362QVector<statechartmodel::StatePtr>
365 QVector<statechartmodel::StatePtr> result;
369 result.push_back(state);
370 GetAllSubstatesRecursively(state, result, localOnly);
374 for (
const auto&
child : children)
376 for (
const auto& state :
child->getAllStatesRecursively(localOnly))
378 result.push_back(state);
388 QVector<statechartmodel::StatePtr>& result,
389 bool localOnly)
const
391 for (
const auto& substate : state->getSubstates())
393 const auto& stateClass = substate->getStateClass();
395 if (stateClass && (!localOnly || substate->getType() != eRemoteState))
397 result.push_back(stateClass);
398 GetAllSubstatesRecursively(stateClass, result, localOnly);
408 return parentNode.lock()->getNestingLevelRelativeToGroup() + 1;
417 std::string
str = name.toUtf8().data();
418 boost::regex nameRegex(
"[a-zA-Z][a-zA-Z0-9]*");
420 return boost::regex_match(
str, what, nameRegex);
423QList<StateTreeNodePtr>
432 return stateIsPublic;
void appendChild(StateTreeNodePtr child)
std::filesystem::path getBoostHFilePath(Path pathType=Path::Absolute) const
QVector< statechartmodel::StatePtr > getAllStatesRecursively(bool localOnly) const
QVector< StateTreeNodePtr > getAllSubNodesRecursively() const
int getNestingLevelRelativeToGroup()
armarx::statechartmodel::StatePtr getState() const
std::filesystem::path getBoostPath(std::filesystem::path parentPath) const
bool isFolderOrGroup() const
void setPublic(bool isPublic)
std::filesystem::path getBoostGeneratedHFilePath(Path pathType=Path::Absolute) const
std::filesystem::path getAbsoluteBoostPath() const
StateTreeNodePtr child(int row)
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)
bool getCppExists() const
StateTreeNodePtr getParent() const
StateTreeNodePtr findNodeByStateName(QString name)
StateTreeNodePtr getClosestParentFolderOrGroupNode()
std::filesystem::path getBoostCppFilePath(Path pathType=Path::Absolute) const
QString getDisplay() const
Class that offers the main functionality needed to create a statechart.
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
double a(double t, double a0, double j)
std::shared_ptr< State > StatePtr
This file offers overloads of toIce() and fromIce() functions for STL container types.
std::shared_ptr< StatechartGroup > StatechartGroupPtr
std::shared_ptr< StateTreeNode > StateTreeNodePtr