bpmn++
A BPMN parser library, written in C++
Loading...
Searching...
No Matches
ChildNode.h
Go to the documentation of this file.
1#ifndef BPMN_ChildNode_H
2#define BPMN_ChildNode_H
3
4#include <memory>
5#include <vector>
6#include <optional>
7#include "Node.h"
8
9namespace BPMN {
10
11class SequenceFlow;
12
13/**
14 * @brief Base class for BPMN elements within a Scope.
15 */
16class ChildNode : virtual public Node {
17 friend class Model;
18public:
20
21 /// @brief Returns the first ancestor node representing type T.
22 template<typename T> Node* ancestor() {
23 BPMN::Node* node = this;
24 while ( node->represents<ChildNode>() ) {
25 node = (Node*)node->as<ChildNode>()->parent;
26 if ( node->represents<T>() ) {
27 return node;
28 }
29 }
30 return nullptr;
31 }
32
33 /// @brief Returns the first ancestor node representing type T.
34 template<typename T> const Node* ancestor() const {
35 const BPMN::Node* node = this;
36 while ( node->represents<ChildNode>() ) {
37 node = (Node*)node->as<ChildNode>()->parent;
38 if ( node->represents<T>() ) {
39 return node;
40 }
41 }
42 return nullptr;
43 }
44
45 /// @brief Reference to the parent node.
47};
48
49} // namespace BPMN
50
51#endif // BPMN_ChildNode_H
XML::bpmn::tBaseElement * element
Definition BaseElement.h:20
Base class for BPMN elements within a Scope.
Definition ChildNode.h:16
const Node * ancestor() const
Returns the first ancestor node representing type T.
Definition ChildNode.h:34
Scope * parent
Reference to the parent node.
Definition ChildNode.h:46
Node * ancestor()
Returns the first ancestor node representing type T.
Definition ChildNode.h:22
T * as()
Casts the element to the specified type T.
Definition Element.h:38
T * represents()
Attempts to cast the element to the specified type T.
Definition Element.h:21
Represents a BPMN model with all its processes and message flows.
Definition Model.h:170
Base class for all nodes in a BPMN model.
Definition Node.h:24
Base class for BPMN elements that may contain a ChildNode elements.
Definition Scope.h:24
The BPMN namespace contains linked classes representing a BPMN model.