Commit 99e9ffa4 authored by mattijs's avatar mattijs
Browse files

deletion of owned objects

parent 9b15a7e2
......@@ -177,12 +177,16 @@ bool Foam::objectRegistry::checkOut(regIOobject& io) const
}
else
{
regIOobject* object = iter();
bool hasErased = const_cast<objectRegistry&>(*this).erase(iter);
if (io.ownedByRegistry())
{
delete iter();
delete object;
}
return const_cast<objectRegistry&>(*this).erase(iter);
return hasErased;
}
}
else
......
......@@ -105,6 +105,29 @@ const Type& Foam::MeshObject<Mesh, Type>::New
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
template<class Mesh, class Type>
bool Foam::MeshObject<Mesh, Type>::Delete(const Mesh& mesh)
{
if (mesh.db().objectRegistry::foundObject<Type>(Type::typeName))
{
return mesh.db().objectRegistry::checkOut
(
const_cast<Type&>
(
mesh.db().objectRegistry::lookupObject<Type>
(
Type::typeName
)
)
);
}
else
{
return false;
}
}
template<class Mesh, class Type>
Foam::MeshObject<Mesh, Type>::~MeshObject()
{
......
......@@ -78,6 +78,8 @@ public:
// Destructor
static bool Delete(const Mesh& mesh);
virtual ~MeshObject();
......
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