Part: Geometry extensions constness correction
This commit is contained in:
committed by
abdullahtahiriyo
parent
5c492f727c
commit
88e542b345
@@ -258,9 +258,9 @@ boost::uuids::uuid Geometry::getTag() const
|
||||
return tag;
|
||||
}
|
||||
|
||||
const std::vector<std::weak_ptr<GeometryExtension>> Geometry::getExtensions() const
|
||||
std::vector<std::weak_ptr<const GeometryExtension>> Geometry::getExtensions() const
|
||||
{
|
||||
std::vector<std::weak_ptr<GeometryExtension>> wp;
|
||||
std::vector<std::weak_ptr<const GeometryExtension>> wp;
|
||||
|
||||
for(auto & ext:extensions)
|
||||
wp.push_back(ext);
|
||||
@@ -288,7 +288,7 @@ bool Geometry::hasExtension(std::string name) const
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::weak_ptr<GeometryExtension> Geometry::getExtension(Base::Type type) const
|
||||
std::weak_ptr<const GeometryExtension> Geometry::getExtension(Base::Type type) const
|
||||
{
|
||||
for( auto ext : extensions) {
|
||||
if(ext->getTypeId() == type)
|
||||
@@ -298,7 +298,7 @@ const std::weak_ptr<GeometryExtension> Geometry::getExtension(Base::Type type) c
|
||||
throw Base::ValueError("No geometry extension of the requested type.");
|
||||
}
|
||||
|
||||
const std::weak_ptr<GeometryExtension> Geometry::getExtension(std::string name) const
|
||||
std::weak_ptr<const GeometryExtension> Geometry::getExtension(std::string name) const
|
||||
{
|
||||
for( auto ext : extensions) {
|
||||
if(ext->getName() == name)
|
||||
|
||||
@@ -101,12 +101,12 @@ public:
|
||||
/// returns the tag of the geometry object
|
||||
boost::uuids::uuid getTag() const;
|
||||
|
||||
const std::vector<std::weak_ptr<GeometryExtension>> getExtensions() const;
|
||||
std::vector<std::weak_ptr<const GeometryExtension>> getExtensions() const;
|
||||
|
||||
bool hasExtension(Base::Type type) const;
|
||||
bool hasExtension(std::string name) const;
|
||||
const std::weak_ptr<GeometryExtension> getExtension(Base::Type type) const;
|
||||
const std::weak_ptr<GeometryExtension> getExtension(std::string name) const;
|
||||
std::weak_ptr<const GeometryExtension> getExtension(Base::Type type) const;
|
||||
std::weak_ptr<const GeometryExtension> getExtension(std::string name) const;
|
||||
void setExtension(std::unique_ptr<GeometryExtension> &&geo);
|
||||
void deleteExtension(Base::Type type);
|
||||
void deleteExtension(std::string name);
|
||||
|
||||
@@ -245,10 +245,10 @@ PyObject* GeometryPy::getExtensionOfType(PyObject *args)
|
||||
|
||||
if(type != Base::Type::badType()) {
|
||||
try {
|
||||
std::shared_ptr<GeometryExtension> ext(this->getGeometryPtr()->getExtension(type));
|
||||
std::shared_ptr<const GeometryExtension> ext(this->getGeometryPtr()->getExtension(type));
|
||||
|
||||
// we create a copy and transfer this copy's memory management responsibility to Python
|
||||
PyObject* cpy = static_cast<GeometryExtensionPy *>(ext->getPyObject())->copy(Py::new_reference_to(Py::Tuple(size_t(0))));
|
||||
PyObject* cpy = static_cast<GeometryExtensionPy *>(std::const_pointer_cast<GeometryExtension>(ext)->getPyObject())->copy(Py::new_reference_to(Py::Tuple(size_t(0))));
|
||||
|
||||
return cpy;
|
||||
}
|
||||
@@ -279,10 +279,10 @@ PyObject* GeometryPy::getExtensionOfName(PyObject *args)
|
||||
if (PyArg_ParseTuple(args, "s", &o)) {
|
||||
|
||||
try {
|
||||
std::shared_ptr<GeometryExtension> ext(this->getGeometryPtr()->getExtension(std::string(o)));
|
||||
std::shared_ptr<const GeometryExtension> ext(this->getGeometryPtr()->getExtension(std::string(o)));
|
||||
|
||||
// we create a copy and transfer this copy's memory management responsibility to Python
|
||||
PyObject* cpy = static_cast<GeometryExtensionPy *>(ext->getPyObject())->copy(Py::new_reference_to(Py::Tuple(size_t(0))));
|
||||
PyObject* cpy = static_cast<GeometryExtensionPy *>(std::const_pointer_cast<GeometryExtension>(ext)->getPyObject())->copy(Py::new_reference_to(Py::Tuple(size_t(0))));
|
||||
|
||||
return cpy;
|
||||
}
|
||||
@@ -404,7 +404,7 @@ PyObject* GeometryPy::getExtensions(PyObject *args)
|
||||
}
|
||||
|
||||
try {
|
||||
const std::vector<std::weak_ptr<GeometryExtension>> ext = this->getGeometryPtr()->getExtensions();
|
||||
const std::vector<std::weak_ptr<const GeometryExtension>> ext = this->getGeometryPtr()->getExtensions();
|
||||
|
||||
PyObject* list = PyList_New(ext.size());
|
||||
|
||||
@@ -412,7 +412,8 @@ PyObject* GeometryPy::getExtensions(PyObject *args)
|
||||
|
||||
for (std::size_t i=0; i<ext.size(); ++i) {
|
||||
|
||||
std::shared_ptr<GeometryExtension> p = ext[i].lock();
|
||||
// const casting only to get the Python object to make a copy
|
||||
std::shared_ptr<GeometryExtension> p = std::const_pointer_cast<GeometryExtension>(ext[i].lock());
|
||||
|
||||
if(p) {
|
||||
// we create a python copy and add it to the list
|
||||
|
||||
Reference in New Issue
Block a user