extend C++ library API
This commit is contained in:
@@ -2220,6 +2220,23 @@ std::list<StateMachine*> Document::get_state_machines()
|
||||
return result;
|
||||
}
|
||||
|
||||
const StateMachine* Document::get_parent_sm(const Element* element) const
|
||||
{
|
||||
if (element != NULL) {
|
||||
ElementType type = element->get_type();
|
||||
if (type == elementRoot) {
|
||||
return NULL;
|
||||
} else if (type == elementSM) {
|
||||
return static_cast<const StateMachine*>(element);
|
||||
} else {
|
||||
CYB_ASSERT(element->get_parent());
|
||||
return get_parent_sm(element->get_parent());
|
||||
}
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
std::ostream& Document::dump(std::ostream& os) const
|
||||
{
|
||||
Element::dump(os);
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Cyberiada {
|
||||
// -----------------------------------------------------------------------------
|
||||
// Cyberiada diagram element types:
|
||||
enum ElementType {
|
||||
elementRoot, // document (root namespace)
|
||||
elementRoot = 0, // document (root namespace)
|
||||
elementSM, // state machine
|
||||
elementSimpleState, // simple state
|
||||
elementCompositeState, // composite state
|
||||
@@ -624,6 +624,7 @@ namespace Cyberiada {
|
||||
|
||||
std::list<const StateMachine*> get_state_machines() const;
|
||||
std::list<StateMachine*> get_state_machines();
|
||||
const StateMachine* get_parent_sm(const Element* element) const;
|
||||
|
||||
protected:
|
||||
virtual std::ostream& dump(std::ostream& os) const;
|
||||
|
||||
Reference in New Issue
Block a user