ENH: additional std::unique_ptr support for regIOobject and IOobjectList
- regIOobject::store(std::unique_ptr<...>&& ptr) - IOobjectList::add(std::unique_ptr<...>&& ptr) STYLE: io.globalCaseName() instead of io.time().globalCaseName() [#3007]
This commit is contained in:
parent
6ac572a179
commit
0dcc53ab03
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2016-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -228,6 +228,9 @@ public:
|
||||
|
||||
// Basic methods
|
||||
|
||||
//- Move insert IOobject into the list
|
||||
inline bool add(std::unique_ptr<IOobject>&& objectPtr);
|
||||
|
||||
//- Move insert IOobject into the list
|
||||
inline bool add(autoPtr<IOobject>& objectPtr);
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2022-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2022-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -109,6 +109,17 @@ inline Foam::IOobjectList::IOobjectList
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline bool Foam::IOobjectList::add(std::unique_ptr<IOobject>&& objectPtr)
|
||||
{
|
||||
if (objectPtr)
|
||||
{
|
||||
return insert(objectPtr->name(), std::move(objectPtr));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::IOobjectList::add(autoPtr<IOobject>& objectPtr)
|
||||
{
|
||||
if (objectPtr)
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -195,6 +195,12 @@ public:
|
||||
template<class Type>
|
||||
inline static Type& store(Type* p);
|
||||
|
||||
//- Transfer pointer ownership to its registry.
|
||||
// Resets (clears) the parameter.
|
||||
// \return reference to the stored object
|
||||
template<class Type>
|
||||
inline static Type& store(std::unique_ptr<Type>&& ptr);
|
||||
|
||||
//- Transfer pointer ownership to its registry.
|
||||
// Resets (clears) the parameter.
|
||||
// \return reference to the stored object
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||
Copyright (C) 2018-2024 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -80,6 +80,14 @@ inline Type& Foam::regIOobject::store(Type* p)
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline Type& Foam::regIOobject::store(std::unique_ptr<Type>&& ptr)
|
||||
{
|
||||
// Pass management to objectRegistry
|
||||
return store(ptr.release());
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline Type& Foam::regIOobject::store(autoPtr<Type>& ptr)
|
||||
{
|
||||
@ -182,6 +190,7 @@ inline Type& Foam::regIOobject::store(tmp<Type>&& ptr)
|
||||
|
||||
inline void Foam::regIOobject::release(const bool unregister) noexcept
|
||||
{
|
||||
// Note: could also return the old ownedByRegistry_ value
|
||||
ownedByRegistry_ = false;
|
||||
if (unregister)
|
||||
{
|
||||
|
@ -1413,7 +1413,7 @@ Foam::fileName Foam::fileOperation::processorsCasePath
|
||||
const word& procsDir
|
||||
) const
|
||||
{
|
||||
return io.rootPath()/io.time().globalCaseName()/procsDir;
|
||||
return io.rootPath()/io.globalCaseName()/procsDir;
|
||||
}
|
||||
|
||||
|
||||
|
@ -198,8 +198,10 @@ Foam::fileOperations::masterUncollatedFileOperation::filePathInfo
|
||||
)
|
||||
{
|
||||
fileName parentPath =
|
||||
io.rootPath()/io.time().globalCaseName()
|
||||
/io.instance()/io.db().dbDir()/io.local()/io.name();
|
||||
(
|
||||
io.rootPath()/io.globalCaseName()
|
||||
/io.instance()/io.db().dbDir()/io.local()/io.name()
|
||||
);
|
||||
|
||||
if (isFileOrDir(isFile, parentPath))
|
||||
{
|
||||
@ -356,7 +358,7 @@ Foam::fileOperations::masterUncollatedFileOperation::localObjectPath
|
||||
case fileOperation::PARENTOBJECT:
|
||||
{
|
||||
return
|
||||
io.rootPath()/io.time().globalCaseName()
|
||||
io.rootPath()/io.globalCaseName()
|
||||
/io.instance()/io.db().dbDir()/io.local()/io.name();
|
||||
}
|
||||
break;
|
||||
|
@ -108,13 +108,15 @@ Foam::fileName Foam::fileOperations::uncollatedFileOperation::filePathInfo
|
||||
{
|
||||
// Constant & system can come from global case
|
||||
|
||||
fileName parentObjectPath =
|
||||
io.rootPath()/io.time().globalCaseName()
|
||||
/io.instance()/io.db().dbDir()/io.local()/io.name();
|
||||
fileName parentPath =
|
||||
(
|
||||
io.rootPath()/io.globalCaseName()
|
||||
/io.instance()/io.db().dbDir()/io.local()/io.name()
|
||||
);
|
||||
|
||||
if (isFileOrDir(isFile, parentObjectPath))
|
||||
if (isFileOrDir(isFile, parentPath))
|
||||
{
|
||||
return parentObjectPath;
|
||||
return parentPath;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -250,8 +250,10 @@ Foam::word Foam::distributedTriSurfaceMesh::findLocalInstance
|
||||
|
||||
// Search in parent directory
|
||||
fileName parentDir =
|
||||
io.rootPath()/io.time().globalCaseName()
|
||||
/io.instance()/io.db().dbDir()/io.local()/io.name();
|
||||
(
|
||||
io.rootPath()/io.globalCaseName()
|
||||
/io.instance()/io.db().dbDir()/io.local()/io.name()
|
||||
);
|
||||
|
||||
if (fileHandler().isDir(parentDir))
|
||||
{
|
||||
@ -280,9 +282,11 @@ Foam::word Foam::distributedTriSurfaceMesh::findLocalInstance
|
||||
continue;
|
||||
}
|
||||
|
||||
fileName parentDir =
|
||||
io.rootPath()/io.time().globalCaseName()
|
||||
/ts[instanceI].name()/io.db().dbDir()/io.local()/io.name();
|
||||
parentDir =
|
||||
(
|
||||
io.rootPath()/io.globalCaseName()
|
||||
/ts[instanceI].name()/io.db().dbDir()/io.local()/io.name()
|
||||
);
|
||||
|
||||
if (fileHandler().isDir(parentDir))
|
||||
{
|
||||
@ -301,9 +305,11 @@ Foam::word Foam::distributedTriSurfaceMesh::findLocalInstance
|
||||
// constant function of the time, because the latter points to
|
||||
// the case constant directory in parallel cases
|
||||
|
||||
fileName parentDir =
|
||||
io.rootPath()/io.time().globalCaseName()
|
||||
/io.time().constant()/io.db().dbDir()/io.local()/io.name();
|
||||
parentDir =
|
||||
(
|
||||
io.rootPath()/io.globalCaseName()
|
||||
/io.time().constant()/io.db().dbDir()/io.local()/io.name()
|
||||
);
|
||||
|
||||
if (fileHandler().isDir(parentDir))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user