ENH: add Function1::NewIfPresent without a redirect type

- simplifies handling, consistent with PatchFunction1

STYLE: use Function1 NewIfPresent instead of separate found/New
This commit is contained in:
Mark Olesen
2023-02-17 17:19:14 +01:00
parent aef990f8df
commit b71a05a72f
9 changed files with 94 additions and 61 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2022 OpenCFD Ltd.
Copyright (C) 2018-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -119,7 +119,11 @@ protected:
public:
typedef Type returnType;
// Data Types
//- The return type
typedef Type returnType;
//- Runtime type information
TypeName("Function1")
@ -196,12 +200,20 @@ public:
const bool mandatory = true
);
//- An optional selector
//- An optional selector, with fallback redirection
static autoPtr<Function1<Type>> NewIfPresent
(
const word& entryName,
const dictionary& dict,
const word& redirectType,
const objectRegistry* obrPtr = nullptr
);
//- An optional selector, without fallback redirection
static autoPtr<Function1<Type>> NewIfPresent
(
const word& entryName,
const dictionary& dict,
const word& redirectType = word::null,
const objectRegistry* obrPtr = nullptr
);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2021 OpenCFD Ltd.
Copyright (C) 2018-2023 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -225,6 +225,20 @@ Foam::Function1<Type>::NewIfPresent
}
template<class Type>
Foam::autoPtr<Foam::Function1<Type>>
Foam::Function1<Type>::NewIfPresent
(
const word& entryName,
const dictionary& dict,
const objectRegistry* obrPtr
)
{
// mandatory = false
return Function1<Type>::New(entryName, dict, word::null, obrPtr, false);
}
template<class Type>
Foam::refPtr<Foam::Function1<Type>>
Foam::Function1<Type>::New