mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
deletion of owned objects
This commit is contained in:
@ -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();
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user