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)
|
if (objectRegistry::debug)
|
||||||
{
|
{
|
||||||
Pout<< "objectRegistry::checkIn(regIOobject&) : "
|
Pout<< "objectRegistry::checkIn : "
|
||||||
<< name() << " : checking in " << io.name()
|
<< name() << " : checking in " << io->name()
|
||||||
<< " of type " << io.type()
|
<< " of type " << io->type()
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
objectRegistry& obr = const_cast<objectRegistry&>(*this);
|
objectRegistry& obr = const_cast<objectRegistry&>(*this);
|
||||||
|
|
||||||
bool ok = obr.insert(io.name(), &io);
|
bool ok = obr.insert(io->name(), io);
|
||||||
|
|
||||||
if (!ok && objectRegistry::debug)
|
if (!ok && objectRegistry::debug)
|
||||||
{
|
{
|
||||||
WarningInFunction
|
WarningInFunction
|
||||||
<< name() << " : attempted to checkIn object with name "
|
<< name() << " : attempted to checkIn object with name "
|
||||||
<< io.name() << " which was already checked in"
|
<< io->name() << " which was already checked in"
|
||||||
<< endl;
|
<< 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);
|
objectRegistry& obr = const_cast<objectRegistry&>(*this);
|
||||||
|
|
||||||
iterator iter = obr.find(io.name());
|
iterator iter = obr.find(io->name());
|
||||||
|
|
||||||
if (iter.found())
|
if (iter.found())
|
||||||
{
|
{
|
||||||
if (objectRegistry::debug)
|
if (objectRegistry::debug)
|
||||||
{
|
{
|
||||||
Pout<< "objectRegistry::checkOut(regIOobject&) : "
|
Pout<< "objectRegistry::checkOut : "
|
||||||
<< name() << " : checking out " << io.name()
|
<< name() << " : checking out " << io->name()
|
||||||
|
<< " of type " << io->type()
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iter.val() != &io)
|
if (iter.val() != io)
|
||||||
{
|
{
|
||||||
if (objectRegistry::debug)
|
if (objectRegistry::debug)
|
||||||
{
|
{
|
||||||
@ -299,8 +304,8 @@ bool Foam::objectRegistry::checkOut(regIOobject& io) const
|
|||||||
|
|
||||||
if (objectRegistry::debug)
|
if (objectRegistry::debug)
|
||||||
{
|
{
|
||||||
Pout<< "objectRegistry::checkOut(regIOobject&) : "
|
Pout<< "objectRegistry::checkOut : "
|
||||||
<< name() << " : could not find " << io.name() << " in registry"
|
<< name() << " : could not find " << io->name() << " in registry"
|
||||||
<< endl;
|
<< 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
|
bool Foam::objectRegistry::checkOut(const word& key) const
|
||||||
{
|
{
|
||||||
return const_cast<objectRegistry&>(*this).erase(key);
|
return const_cast<objectRegistry&>(*this).erase(key);
|
||||||
|
|||||||
@ -452,14 +452,21 @@ public:
|
|||||||
|
|
||||||
// Edit
|
// Edit
|
||||||
|
|
||||||
|
//- Add a regIOobject to registry. A nullptr is ignored.
|
||||||
|
bool checkIn(regIOobject* io) const;
|
||||||
|
|
||||||
//- Add a regIOobject to registry
|
//- Add a regIOobject to registry
|
||||||
bool checkIn(regIOobject& io) const;
|
bool checkIn(regIOobject& io) const;
|
||||||
|
|
||||||
//- Remove a regIOobject from registry and frees memory if the
|
//- Remove a regIOobject from registry and free memory if the
|
||||||
//- object is ownedByRegistry
|
//- 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;
|
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
|
//- object is ownedByRegistry
|
||||||
bool checkOut(const word& key) const;
|
bool checkOut(const word& key) const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user