Closed Moop204 closed 3 years ago
I'll answer for C++,
auto component = std::dynamic_pointer_cast<libcellml::Component>(entity->parent())
auto model = std::dynamic_pointer_cast<libcellml::Model>(entity->parent())
if (component != nullptr) {
// it's a component.
} else if (model != nullptr) {
// it's a model.
}
Thank you, to be complete I will also include the javascript solution.
component = new libcellml.Component();
...
parent = component.parent();
if (parent instanceof libcellml.Component) {
// Component
} else {
// Model
}
If I needed to take the parent of a Component, how would I be able to determine if it is a Model or another Component?