Skip to content

Support abstract classes implemented in Python that inherit SysModel #1191

@juan-g-bonilla

Description

@juan-g-bonilla

Currently, SysModel classes can be subclassed in Python to implement the UpdateState and Reset methods to create models in Python. However, it is not possible to create a subclass of SysModel in C++ with virtual methods, and have those methods inplemented in Python.

The file src/architecture/_GeneralModuleFiles/py_sys_model.i has two main features to support Python SysModel: improved error logging when errors originate in Python in UpdateState and Reset, and a safety check that the C++ constructor is called. To do the error logging, we manually wrap those two functions. For a safety check, we make use of a metaclass.

For the desired feature of having subclasses of SysModel, we need to get rid of the metaclass (which interacts weirdly with the SWIG class with directors, which also use metaclasses) and also we need to apply the error logging wrapper to arbitrary methods, not just UpdateState and Reset. Moreover, we like to make implementing these classes as easily as possible, without having to repeat too much code.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions