mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: support checkIn/checkOut with pointers (#1276)
This commit is contained in:
committed by
Andrew Heather
parent
887236a155
commit
ef0d15546a
@ -239,25 +239,27 @@ Foam::label Foam::objectRegistry::getEvent() const
|
||||
}
|
||||
|
||||
|
||||
bool Foam::objectRegistry::checkIn(regIOobject& io) const
|
||||
bool Foam::objectRegistry::checkIn(regIOobject* io) const
|
||||
{
|
||||
if (!io) return false;
|
||||
|
||||
if (objectRegistry::debug)
|
||||
{
|
||||
Pout<< "objectRegistry::checkIn(regIOobject&) : "
|
||||
<< name() << " : checking in " << io.name()
|
||||
<< " of type " << io.type()
|
||||
Pout<< "objectRegistry::checkIn : "
|
||||
<< name() << " : checking in " << io->name()
|
||||
<< " of type " << io->type()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
objectRegistry& obr = const_cast<objectRegistry&>(*this);
|
||||
|
||||
bool ok = obr.insert(io.name(), &io);
|
||||
bool ok = obr.insert(io->name(), io);
|
||||
|
||||
if (!ok && objectRegistry::debug)
|
||||
{
|
||||
WarningInFunction
|
||||
<< name() << " : attempted to checkIn object with name "
|
||||
<< io.name() << " which was already checked in"
|
||||
<< io->name() << " which was already checked in"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
@ -265,22 +267,25 @@ bool Foam::objectRegistry::checkIn(regIOobject& io) const
|
||||
}
|
||||
|
||||
|
||||
bool Foam::objectRegistry::checkOut(regIOobject& io) const
|
||||
bool Foam::objectRegistry::checkOut(regIOobject* io) const
|
||||
{
|
||||
if (!io) return false;
|
||||
|
||||
objectRegistry& obr = const_cast<objectRegistry&>(*this);
|
||||
|
||||
iterator iter = obr.find(io.name());
|
||||
iterator iter = obr.find(io->name());
|
||||
|
||||
if (iter.found())
|
||||
{
|
||||
if (objectRegistry::debug)
|
||||
{
|
||||
Pout<< "objectRegistry::checkOut(regIOobject&) : "
|
||||
<< name() << " : checking out " << io.name()
|
||||
Pout<< "objectRegistry::checkOut : "
|
||||
<< name() << " : checking out " << io->name()
|
||||
<< " of type " << io->type()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
if (iter.val() != &io)
|
||||
if (iter.val() != io)
|
||||
{
|
||||
if (objectRegistry::debug)
|
||||
{
|
||||
@ -299,8 +304,8 @@ bool Foam::objectRegistry::checkOut(regIOobject& io) const
|
||||
|
||||
if (objectRegistry::debug)
|
||||
{
|
||||
Pout<< "objectRegistry::checkOut(regIOobject&) : "
|
||||
<< name() << " : could not find " << io.name() << " in registry"
|
||||
Pout<< "objectRegistry::checkOut : "
|
||||
<< name() << " : could not find " << io->name() << " in registry"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
@ -308,6 +313,18 @@ bool Foam::objectRegistry::checkOut(regIOobject& io) const
|
||||
}
|
||||
|
||||
|
||||
bool Foam::objectRegistry::checkIn(regIOobject& io) const
|
||||
{
|
||||
return checkIn(&io);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::objectRegistry::checkOut(regIOobject& io) const
|
||||
{
|
||||
return checkOut(&io);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::objectRegistry::checkOut(const word& key) const
|
||||
{
|
||||
return const_cast<objectRegistry&>(*this).erase(key);
|
||||
|
||||
@ -452,14 +452,21 @@ public:
|
||||
|
||||
// Edit
|
||||
|
||||
//- Add a regIOobject to registry. A nullptr is ignored.
|
||||
bool checkIn(regIOobject* io) const;
|
||||
|
||||
//- Add a regIOobject to registry
|
||||
bool checkIn(regIOobject& io) const;
|
||||
|
||||
//- Remove a regIOobject from registry and frees memory if the
|
||||
//- object is ownedByRegistry
|
||||
//- Remove a regIOobject from registry and free memory if the
|
||||
//- object is ownedByRegistry. A nullptr is ignored.
|
||||
bool checkOut(regIOobject* io) const;
|
||||
|
||||
//- Remove a regIOobject from registry and free memory if the
|
||||
//- object is ownedByRegistry.
|
||||
bool checkOut(regIOobject& io) const;
|
||||
|
||||
//- Remove a regIOobject by name from registry and frees memory if the
|
||||
//- Remove a regIOobject by name from registry and free memory if the
|
||||
//- object is ownedByRegistry
|
||||
bool checkOut(const word& key) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user