mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: define IOobjectList::csorted(), deprecate some sorted() const methods
- prefer csorted() method for const access since it ensures that the return values are also const pointers (for example) even if the object itself can be accessed as a non-const. - the csorted() method already existed for HashTable and objectRegistry, but now added to IOobjectList for method name consistency (even although the IOobjectList only has a const-access version) ENH: objectRegistry with templated strict lookup - for lookupClass and csorted/sorted. Allows isType restriction as a compile-time specification.
This commit is contained in:
@ -85,7 +85,7 @@ Description
|
||||
|
||||
fileNameList procDirs
|
||||
(
|
||||
DirLister::dirs(".").sorted<fileName>(matchProcs)
|
||||
DirLister::dirs(".").csorted<fileName>(matchProcs)
|
||||
);
|
||||
}
|
||||
\endcode
|
||||
@ -206,11 +206,11 @@ public:
|
||||
|
||||
//- Return a complete list of names, sorted in natural order
|
||||
template<class StringType=Foam::word>
|
||||
List<StringType> sorted() const;
|
||||
List<StringType> csorted() const;
|
||||
|
||||
//- Return complete list of names, sorted in natural order
|
||||
template<class StringType=Foam::word, class UnaryPredicate>
|
||||
List<StringType> sorted
|
||||
List<StringType> csorted
|
||||
(
|
||||
const UnaryPredicate& pred,
|
||||
const bool prune = false
|
||||
|
||||
@ -70,23 +70,23 @@ Foam::List<StringType> Foam::DirLister::list() const
|
||||
|
||||
|
||||
template<class StringType, class UnaryPredicate>
|
||||
Foam::List<StringType> Foam::DirLister::sorted
|
||||
Foam::List<StringType> Foam::DirLister::csorted
|
||||
(
|
||||
const UnaryPredicate& pred,
|
||||
const bool prune
|
||||
) const
|
||||
{
|
||||
List<StringType> lst(list<StringType>(pred, prune));
|
||||
sort(lst, stringOps::natural_sort());
|
||||
List<StringType> list(list<StringType>(pred, prune));
|
||||
Foam::sort(list, stringOps::natural_sort());
|
||||
|
||||
return lst;
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
template<class StringType>
|
||||
Foam::List<StringType> Foam::DirLister::sorted() const
|
||||
Foam::List<StringType> Foam::DirLister::csorted() const
|
||||
{
|
||||
return sorted<StringType>(predicates::always());
|
||||
return csorted<StringType>(predicates::always());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -162,7 +162,7 @@ int main(int argc, char *argv[])
|
||||
Info<< "dirList: "
|
||||
<< flatOutput
|
||||
(
|
||||
DirLister::dirs(".").sorted<fileName>(relist)
|
||||
DirLister::dirs(".").csorted<fileName>(relist)
|
||||
) << nl;
|
||||
}
|
||||
|
||||
|
||||
@ -75,8 +75,8 @@ int main()
|
||||
}
|
||||
|
||||
|
||||
Info<< "\ntable1 sorted() :" << endl;
|
||||
for (const auto& iter : table1.sorted())
|
||||
Info<< "\ntable1 csorted() :" << endl;
|
||||
for (const auto& iter : table1.csorted())
|
||||
{
|
||||
Info<< " " << iter.key() << " => " << iter.val() << nl;
|
||||
}
|
||||
@ -100,7 +100,7 @@ int main()
|
||||
}
|
||||
|
||||
Info<< "\nInplace modified - via sorted() access :" << endl;
|
||||
for (const auto& iter : table1.sorted())
|
||||
for (const auto& iter : table1.csorted())
|
||||
{
|
||||
Info<< " " << iter.key() << " => " << iter.val() << nl;
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2017-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2017-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -290,14 +290,14 @@ int main(int argc, char *argv[])
|
||||
Info<< "Time: " << runTime.timeName() << nl;
|
||||
|
||||
report(objects);
|
||||
report(objects.sorted());
|
||||
report(objects.csorted());
|
||||
|
||||
report(objects.sorted<volScalarField>());
|
||||
report(objects.sorted<volVectorField>());
|
||||
report(objects.csorted<volScalarField>());
|
||||
report(objects.csorted<volVectorField>());
|
||||
|
||||
// Extra checks
|
||||
report<volScalarField>(objects.sorted<volScalarField>());
|
||||
report<volScalarField>(objects.sorted<volVectorField>());
|
||||
report<volScalarField>(objects.csorted<volScalarField>());
|
||||
report<volScalarField>(objects.csorted<volVectorField>());
|
||||
|
||||
|
||||
findObjectTest(objects);
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2022 OpenCFD Ltd.
|
||||
Copyright (C) 2022-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -139,7 +139,7 @@ void printInfo(const ensightMesh& mesh, int verbose = 0)
|
||||
FixedList<label, 3> cellStats(Zero);
|
||||
FixedList<label, 3> faceStats(Zero);
|
||||
|
||||
for (const auto& iter : mesh.cellZoneParts().sorted())
|
||||
for (const auto& iter : mesh.cellZoneParts().csorted())
|
||||
{
|
||||
FixedList<label, 3> stats = printPartInfo(iter.val(), verbose);
|
||||
|
||||
@ -149,7 +149,7 @@ void printInfo(const ensightMesh& mesh, int verbose = 0)
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& iter : mesh.faceZoneParts().sorted())
|
||||
for (const auto& iter : mesh.faceZoneParts().csorted())
|
||||
{
|
||||
FixedList<label, 3> stats = printPartInfo(iter.val(), verbose);
|
||||
|
||||
@ -159,7 +159,7 @@ void printInfo(const ensightMesh& mesh, int verbose = 0)
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& iter : mesh.boundaryParts().sorted())
|
||||
for (const auto& iter : mesh.boundaryParts().csorted())
|
||||
{
|
||||
FixedList<label, 3> stats = printPartInfo(iter.val(), verbose);
|
||||
|
||||
|
||||
@ -57,7 +57,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "Found: " << objects << nl << endl;
|
||||
|
||||
for (const IOobject& io : objects.sorted<uniformDimensionedVectorField>())
|
||||
for (const IOobject& io : objects.csorted<uniformDimensionedVectorField>())
|
||||
{
|
||||
if (io.name() == meshObjects::gravity::typeName)
|
||||
{
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2016-2022 OpenCFD Ltd.
|
||||
Copyright (C) 2016-2023 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -78,8 +78,8 @@ void printRegistry
|
||||
Foam::label indent
|
||||
)
|
||||
{
|
||||
UPtrList<const regIOobject> objects(obr.sorted());
|
||||
wordList regNames(obr.sortedNames<objectRegistry>());
|
||||
const UPtrList<const regIOobject> objects(obr.csorted());
|
||||
const wordList regNames(obr.sortedNames<objectRegistry>());
|
||||
|
||||
std::string prefix;
|
||||
for (label i=indent; i; --i)
|
||||
|
||||
@ -145,8 +145,8 @@ void printRegistry
|
||||
Foam::label indent
|
||||
)
|
||||
{
|
||||
UPtrList<const regIOobject> objects(obr.sorted());
|
||||
wordList regNames(obr.sortedNames<objectRegistry>());
|
||||
const UPtrList<const regIOobject> objects(obr.csorted());
|
||||
const wordList regNames(obr.sortedNames<objectRegistry>());
|
||||
|
||||
std::string prefix;
|
||||
for (label i=indent; i; --i)
|
||||
@ -315,7 +315,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
registryTests(mesh);
|
||||
|
||||
report(mesh.sorted<const volScalarField>());
|
||||
report(mesh.csorted<volScalarField>());
|
||||
report(mesh.csorted<volVectorField>());
|
||||
|
||||
Info<< nl;
|
||||
|
||||
Reference in New Issue
Block a user