Commit 718ca558 authored by Markus Mirz's avatar Markus Mirz
Browse files

remove Component from Python classes

parent 79c89b7e
......@@ -47,7 +47,7 @@ namespace Python {
struct Component {
PyObject_HEAD
CPS::Component::Ptr comp;
CPS::IdentifiedObject::Ptr comp;
static void init(Component* self);
......@@ -146,6 +146,6 @@ namespace Python {
static PyTypeObject type;
};
CPS::Component::List compsFromPython(PyObject* list);
CPS::IdentifiedObject::List compsFromPython(PyObject* list);
}
}
......@@ -46,7 +46,7 @@ namespace Python {
// Helper functions to update the python dicts after a C++ method
// adds components or nodes.
void addCppComponent(CPS::Component::Ptr comp);
void addCppComponent(CPS::IdentifiedObject::Ptr comp);
void addCppNode(CPS::TopologicalNode::Ptr node);
void updateDicts();
......
......@@ -39,13 +39,13 @@ PyObject* Python::Component::newfunc(PyTypeObject* type, PyObject *args, PyObjec
void Python::Component::init(Component* self)
{
new (&self->comp) CPS::Component::Ptr(nullptr);
new (&self->comp) CPS::IdentifiedObject::Ptr(nullptr);
}
void Python::Component::dealloc(Python::Component* self)
{
// This is a workaround for a compiler bug: https://stackoverflow.com/a/42647153/8178705
using Ptr = CPS::Component::Ptr;
using Ptr = CPS::IdentifiedObject::Ptr;
self->comp.~Ptr();
......@@ -126,9 +126,9 @@ int Python::Component::setattro(Python::Component* self, PyObject *name, PyObjec
return 0;
}
CPS::Component::List Python::compsFromPython(PyObject* list)
CPS::IdentifiedObject::List Python::compsFromPython(PyObject* list)
{
CPS::Component::List comps;
CPS::IdentifiedObject::List comps;
if (!PyList_Check(list))
throw std::invalid_argument("argument must be a list");
......
......@@ -185,7 +185,7 @@ int Python::Simulation::init(Simulation* self, PyObject *args, PyObject *kwds)
enum Domain domain;
CPS::Logger::Level logLevel = CPS::Logger::Level::info;
CPS::Component::List tearComponents;
CPS::IdentifiedObject::List tearComponents;
PyObject* pyTearComponents = nullptr;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "sO|ddkkiippdppippO", (char **) kwlist,
......
......@@ -29,9 +29,9 @@
using namespace DPsim;
void Python::SystemTopology::addCppComponent(CPS::Component::Ptr comp) {
void Python::SystemTopology::addCppComponent(CPS::IdentifiedObject::Ptr comp) {
Python::Component* pyComp = PyObject_New(Python::Component, &Python::Component::type);
new (&pyComp->comp) CPS::Component::Ptr(nullptr);
new (&pyComp->comp) CPS::IdentifiedObject::Ptr(nullptr);
pyComp->comp = comp;
PyDict_SetItemString(pyComponentDict, comp->name().c_str(), (PyObject*) pyComp);
......@@ -163,7 +163,7 @@ PyObject* Python::SystemTopology::autoDecouple(SystemTopology* self, PyObject* a
if (!PyArg_ParseTuple(args, "d|d", &timestep, &threshold))
return nullptr;
CPS::Component::List newComponents;
CPS::IdentifiedObject::List newComponents;
for (auto it = self->sys->mComponents.begin(); it != self->sys->mComponents.end(); ) {
auto line = std::dynamic_pointer_cast<CPS::DP::Ph1::PiLine>(*it);
if (line) {
......@@ -316,7 +316,7 @@ int Python::SystemTopology::init(Python::SystemTopology *self, PyObject *args, P
return -1;
}
CPS::Component::List compList;
CPS::IdentifiedObject::List compList;
CPS::TopologicalNode::List nodeList;
if (pyNodeList) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment