deletion of owned objects

This commit is contained in:
mattijs
2008-10-21 13:46:32 +01:00
parent 9b15a7e249
commit 99e9ffa46f
3 changed files with 31 additions and 2 deletions

View File

@ -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

View File

@ -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()
{

View File

@ -78,6 +78,8 @@ public:
// Destructor
static bool Delete(const Mesh& mesh);
virtual ~MeshObject();