Materials: External Modules Part 1
Refactored code to support local and external material sources This is the first PR in a series to support external modules. External modules allow materials to be stored in external data sources such as databases or web services. No new functionality is introduced in this PR, rather it is a refactoring of code that will allow for changes to be introduced in future PRs. Minor performance improvements have also been made in the model and material managers. The Python API has been enhanced for many data types to allow for modification within Python.
This commit is contained in:
committed by
Chris Hennes
parent
382720b82e
commit
592406a328
@@ -31,19 +31,8 @@ using namespace Materials;
|
||||
// returns a string which represents the object e.g. when printed in python
|
||||
std::string ModelPropertyPy::representation() const
|
||||
{
|
||||
ModelPropertyPy::PointerType ptr = getModelPropertyPtr();
|
||||
std::stringstream str;
|
||||
str << "Property [Name=(";
|
||||
str << ptr->getName().toStdString();
|
||||
str << "), Type=(";
|
||||
str << ptr->getPropertyType().toStdString();
|
||||
str << "), Units=(";
|
||||
str << ptr->getUnits().toStdString();
|
||||
str << "), URL=(";
|
||||
str << ptr->getURL().toStdString();
|
||||
str << "), Description=(";
|
||||
str << ptr->getDescription().toStdString();
|
||||
str << ")]";
|
||||
str << "<ModelProperty object at " << getModelPropertyPtr() << ">";
|
||||
|
||||
return str.str();
|
||||
}
|
||||
@@ -65,26 +54,97 @@ Py::String ModelPropertyPy::getName() const
|
||||
return Py::String(getModelPropertyPtr()->getName().toStdString());
|
||||
}
|
||||
|
||||
void ModelPropertyPy::setName(Py::String arg)
|
||||
{
|
||||
getModelPropertyPtr()->setName(QString::fromStdString(arg));
|
||||
}
|
||||
|
||||
Py::String ModelPropertyPy::getDisplayName() const
|
||||
{
|
||||
return Py::String(getModelPropertyPtr()->getDisplayName().toStdString());
|
||||
}
|
||||
|
||||
void ModelPropertyPy::setDisplayName(Py::String arg)
|
||||
{
|
||||
getModelPropertyPtr()->setDisplayName(QString::fromStdString(arg));
|
||||
}
|
||||
|
||||
Py::String ModelPropertyPy::getType() const
|
||||
{
|
||||
return Py::String(getModelPropertyPtr()->getPropertyType().toStdString());
|
||||
}
|
||||
|
||||
void ModelPropertyPy::setType(Py::String arg)
|
||||
{
|
||||
getModelPropertyPtr()->setPropertyType(QString::fromStdString(arg));
|
||||
}
|
||||
|
||||
Py::String ModelPropertyPy::getUnits() const
|
||||
{
|
||||
return Py::String(getModelPropertyPtr()->getUnits().toStdString());
|
||||
}
|
||||
|
||||
void ModelPropertyPy::setUnits(Py::String arg)
|
||||
{
|
||||
getModelPropertyPtr()->setUnits(QString::fromStdString(arg));
|
||||
}
|
||||
|
||||
Py::String ModelPropertyPy::getURL() const
|
||||
{
|
||||
return Py::String(getModelPropertyPtr()->getURL().toStdString());
|
||||
}
|
||||
|
||||
void ModelPropertyPy::setURL(Py::String arg)
|
||||
{
|
||||
getModelPropertyPtr()->setURL(QString::fromStdString(arg));
|
||||
}
|
||||
|
||||
Py::String ModelPropertyPy::getDescription() const
|
||||
{
|
||||
return Py::String(getModelPropertyPtr()->getDescription().toStdString());
|
||||
}
|
||||
|
||||
void ModelPropertyPy::setDescription(Py::String arg)
|
||||
{
|
||||
getModelPropertyPtr()->setDescription(QString::fromStdString(arg));
|
||||
}
|
||||
|
||||
Py::List ModelPropertyPy::getColumns() const
|
||||
{
|
||||
Py::List list;
|
||||
|
||||
auto columns = getModelPropertyPtr()->getColumns();
|
||||
for (auto& column : columns) {
|
||||
PyObject* modelPropertyPy = new ModelPropertyPy(new ModelProperty(column));
|
||||
list.append(Py::Object(modelPropertyPy, true));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
Py::String ModelPropertyPy::getInheritance() const
|
||||
{
|
||||
return Py::String(getModelPropertyPtr()->getInheritance().toStdString());
|
||||
}
|
||||
|
||||
Py::Boolean ModelPropertyPy::getInherited() const
|
||||
{
|
||||
return getModelPropertyPtr()->isInherited();
|
||||
}
|
||||
|
||||
PyObject* ModelPropertyPy::addColumn(PyObject* args)
|
||||
{
|
||||
PyObject* object;
|
||||
if (!PyArg_ParseTuple(args, "O!", &ModelPropertyPy::Type, &object)) {
|
||||
return nullptr;
|
||||
}
|
||||
ModelProperty* property = static_cast<ModelPropertyPy*>(object)->getModelPropertyPtr();
|
||||
|
||||
getModelPropertyPtr()->addColumn(*property);
|
||||
Py_INCREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
PyObject* ModelPropertyPy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return nullptr;
|
||||
@@ -93,4 +153,4 @@ PyObject* ModelPropertyPy::getCustomAttributes(const char* /*attr*/) const
|
||||
int ModelPropertyPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user