... | ... | @@ -9,6 +9,38 @@ |
|
|
|
|
|
[[_TOC_]]
|
|
|
|
|
|
### Lookups for New() selectors
|
|
|
|
|
|
\since 2112
|
|
|
|
|
|
```
|
|
|
const word modelType(coeffs.get<word>("type"));
|
|
|
|
|
|
auto* ctorPtr = dictionaryConstructorTable(modelType);
|
|
|
|
|
|
if (!ctorPtr)
|
|
|
{
|
|
|
FatalIOErrorInLookup
|
|
|
(
|
|
|
dict,
|
|
|
"fvOption",
|
|
|
modelType,
|
|
|
*dictionaryConstructorTablePtr_
|
|
|
) << exit(FatalIOError);
|
|
|
}
|
|
|
|
|
|
return autoPtr<option>(ctorPtr(name, modelType, coeffs, mesh));
|
|
|
```
|
|
|
|
|
|
This contains the following aspects:
|
|
|
- The dictionary `get<word>` for retrieval with input checking
|
|
|
- The lookup uses `dictionaryConstructorTable()` instead of the HashTable
|
|
|
which adds in additional checks and compatibility aliases.
|
|
|
- Exit immediately upon error, leaving the _good_ case to drop through.
|
|
|
- Use of the `FatalErrorInLookup` or `FatalIOErrorInLookup` macros to
|
|
|
wrap standard boilerplate text for the output.
|
|
|
|
|
|
|
|
|
### Lookups for New() selectors
|
|
|
|
|
|
\since 1912
|
... | ... | @@ -44,7 +76,7 @@ This contains the following aspects: |
|
|
but we save typing and potential mismatches by using these dedicated
|
|
|
methods.
|
|
|
- Exit immediately upon error, leaving the _good_ case to drop through.
|
|
|
- Use of the `FatalErrorInLookup` or `FatalIOErrorInLookup` macros which
|
|
|
- Use of the `FatalErrorInLookup` or `FatalIOErrorInLookup` macros to
|
|
|
wrap standard boilerplate text for the output.
|
|
|
|
|
|
**Anti-pattern**: The equivalent longhand version (pre-v1912)
|
... | ... | |