mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: simplify/extend IOobjectList code with templated predicates
- replace explicit use of word, wordRe, wordRes, wordHashSet as filters with a MatchPredicate, since they all satisfy the requirements for use a predicate. This change reduces code duplication, allows other matcher types (eg, keyType) as well as lambda functions. - add special treatment for a 'const char*' parameter for lookupClass() and the now-deprecated single item lookup() method to promote these parameters to 'word'.
This commit is contained in:
@ -58,6 +58,20 @@ bool Foam::IOobjectList::checkNames(wordList& masterNames, const bool syncPar)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::IOobjectList::syncNames(wordList& objNames)
|
||||||
|
{
|
||||||
|
if (Pstream::parRun())
|
||||||
|
{
|
||||||
|
// Synchronize names
|
||||||
|
Pstream::combineGather(objNames, ListOps::uniqueEqOp<word>());
|
||||||
|
Pstream::combineScatter(objNames);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort for consistent order on all processors
|
||||||
|
Foam::sort(objNames);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::IOobjectList::IOobjectList()
|
Foam::IOobjectList::IOobjectList()
|
||||||
@ -246,30 +260,10 @@ Foam::IOobject* Foam::IOobjectList::findObject(const word& objName) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::IOobjectList Foam::IOobjectList::lookup(const wordRe& matchName) const
|
Foam::IOobjectList Foam::IOobjectList::lookupClass(const char* clsName) const
|
||||||
{
|
{
|
||||||
return lookupImpl(*this, matchName);
|
// No nullptr check - only called with string literals
|
||||||
}
|
return lookupClass(static_cast<word>(clsName));
|
||||||
|
|
||||||
|
|
||||||
Foam::IOobjectList Foam::IOobjectList::lookup(const wordRes& matchName) const
|
|
||||||
{
|
|
||||||
return lookupImpl(*this, matchName);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::IOobjectList Foam::IOobjectList::lookup
|
|
||||||
(
|
|
||||||
const wordHashSet& matchName
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
return lookupImpl(*this, matchName);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::IOobjectList Foam::IOobjectList::lookupClass(const word& clsName) const
|
|
||||||
{
|
|
||||||
return lookupClassImpl(*this, clsName, predicates::always());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -279,39 +273,12 @@ Foam::HashTable<Foam::wordHashSet> Foam::IOobjectList::classes() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::HashTable<Foam::wordHashSet>
|
|
||||||
Foam::IOobjectList::classes(const wordRe& matchName) const
|
|
||||||
{
|
|
||||||
return classesImpl(*this, matchName);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::HashTable<Foam::wordHashSet>
|
|
||||||
Foam::IOobjectList::classes(const wordRes& matchName) const
|
|
||||||
{
|
|
||||||
return classesImpl(*this, matchName);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::HashTable<Foam::wordHashSet>
|
|
||||||
Foam::IOobjectList::classes(const wordHashSet& matchName) const
|
|
||||||
{
|
|
||||||
return classesImpl(*this, matchName);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::wordList Foam::IOobjectList::names() const
|
Foam::wordList Foam::IOobjectList::names() const
|
||||||
{
|
{
|
||||||
return HashPtrTable<IOobject>::toc();
|
return HashPtrTable<IOobject>::toc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::wordList Foam::IOobjectList::sortedNames() const
|
|
||||||
{
|
|
||||||
return HashPtrTable<IOobject>::sortedToc();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::wordList Foam::IOobjectList::names(const bool syncPar) const
|
Foam::wordList Foam::IOobjectList::names(const bool syncPar) const
|
||||||
{
|
{
|
||||||
wordList objNames(HashPtrTable<IOobject>::toc());
|
wordList objNames(HashPtrTable<IOobject>::toc());
|
||||||
@ -326,7 +293,37 @@ Foam::wordList Foam::IOobjectList::names
|
|||||||
const word& clsName
|
const word& clsName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return namesImpl(*this, clsName, predicates::always(), false);
|
// sort/sync: false, false
|
||||||
|
return namesImpl(*this, clsName, predicates::always(), false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::wordList Foam::IOobjectList::names
|
||||||
|
(
|
||||||
|
const word& clsName,
|
||||||
|
const bool syncPar
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
// sort: false
|
||||||
|
return namesImpl(*this, clsName, predicates::always(), false, syncPar);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::wordList Foam::IOobjectList::sortedNames() const
|
||||||
|
{
|
||||||
|
return HashPtrTable<IOobject>::sortedToc();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::wordList Foam::IOobjectList::sortedNames
|
||||||
|
(
|
||||||
|
const bool syncPar
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
wordList objNames(HashPtrTable<IOobject>::sortedToc());
|
||||||
|
|
||||||
|
checkNames(objNames, syncPar);
|
||||||
|
return objNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -335,122 +332,19 @@ Foam::wordList Foam::IOobjectList::sortedNames
|
|||||||
const word& clsName
|
const word& clsName
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return namesImpl(*this, clsName, predicates::always(), true);
|
// sort/sync: true, false
|
||||||
}
|
return namesImpl(*this, clsName, predicates::always(), true, false);
|
||||||
|
|
||||||
|
|
||||||
Foam::wordList Foam::IOobjectList::names
|
|
||||||
(
|
|
||||||
const word& clsName,
|
|
||||||
const bool syncPar
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
wordList objNames(namesImpl(*this, clsName, predicates::always(), false));
|
|
||||||
|
|
||||||
checkNames(objNames, syncPar);
|
|
||||||
return objNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::wordList Foam::IOobjectList::names
|
|
||||||
(
|
|
||||||
const word& clsName,
|
|
||||||
const wordRe& matchName
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
return namesImpl(*this, clsName, matchName, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::wordList Foam::IOobjectList::sortedNames
|
Foam::wordList Foam::IOobjectList::sortedNames
|
||||||
(
|
(
|
||||||
const word& clsName,
|
const word& clsName,
|
||||||
const wordRe& matchName
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
return namesImpl(*this, clsName, matchName, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::wordList Foam::IOobjectList::names
|
|
||||||
(
|
|
||||||
const word& clsName,
|
|
||||||
const wordRe& matchName,
|
|
||||||
const bool syncPar
|
const bool syncPar
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
wordList objNames(namesImpl(*this, clsName, matchName, false));
|
// sort: true
|
||||||
|
return namesImpl(*this, clsName, predicates::always(), true, syncPar);
|
||||||
checkNames(objNames, syncPar);
|
|
||||||
return objNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::wordList Foam::IOobjectList::names
|
|
||||||
(
|
|
||||||
const word& clsName,
|
|
||||||
const wordRes& matchName
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
return namesImpl(*this, clsName, matchName, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::wordList Foam::IOobjectList::sortedNames
|
|
||||||
(
|
|
||||||
const word& clsName,
|
|
||||||
const wordRes& matchName
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
return namesImpl(*this, clsName, matchName, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::wordList Foam::IOobjectList::names
|
|
||||||
(
|
|
||||||
const word& clsName,
|
|
||||||
const wordRes& matchName,
|
|
||||||
const bool syncPar
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
wordList objNames(namesImpl(*this, clsName, matchName, false));
|
|
||||||
|
|
||||||
checkNames(objNames, syncPar);
|
|
||||||
return objNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::wordList Foam::IOobjectList::names
|
|
||||||
(
|
|
||||||
const word& clsName,
|
|
||||||
const wordHashSet& matchName
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
return namesImpl(*this, clsName, matchName, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::wordList Foam::IOobjectList::sortedNames
|
|
||||||
(
|
|
||||||
const word& clsName,
|
|
||||||
const wordHashSet& matchName
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
return namesImpl(*this, clsName, matchName, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::wordList Foam::IOobjectList::names
|
|
||||||
(
|
|
||||||
const word& clsName,
|
|
||||||
const wordHashSet& matchName,
|
|
||||||
const bool syncPar
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
wordList objNames(namesImpl(*this, clsName, matchName, false));
|
|
||||||
|
|
||||||
checkNames(objNames, syncPar);
|
|
||||||
return objNames;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -65,6 +65,9 @@ class IOobjectList
|
|||||||
// since this is required for consistent ordering across processors.
|
// since this is required for consistent ordering across processors.
|
||||||
static bool checkNames(wordList& masterNames, const bool syncPar);
|
static bool checkNames(wordList& masterNames, const bool syncPar);
|
||||||
|
|
||||||
|
//- Combine names from all processors and sort
|
||||||
|
static void syncNames(wordList& objNames);
|
||||||
|
|
||||||
//- Templated implementation for classes()
|
//- Templated implementation for classes()
|
||||||
template<class MatchPredicate>
|
template<class MatchPredicate>
|
||||||
static HashTable<wordHashSet> classesImpl
|
static HashTable<wordHashSet> classesImpl
|
||||||
@ -74,13 +77,14 @@ class IOobjectList
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Templated implementation for names(), sortedNames()
|
//- Templated implementation for names(), sortedNames()
|
||||||
template<class MatchPredicate>
|
template<class MatchPredicate1, class MatchPredicate2>
|
||||||
static wordList namesImpl
|
static wordList namesImpl
|
||||||
(
|
(
|
||||||
const IOobjectList& list,
|
const IOobjectList& list,
|
||||||
const word& matchClass,
|
const MatchPredicate1& matchClass,
|
||||||
const MatchPredicate& matchName,
|
const MatchPredicate2& matchName,
|
||||||
const bool doSort
|
const bool doSort,
|
||||||
|
const bool syncPar
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Templated implementation for lookup()
|
//- Templated implementation for lookup()
|
||||||
@ -92,12 +96,12 @@ class IOobjectList
|
|||||||
);
|
);
|
||||||
|
|
||||||
//- Templated implementation for lookupClass()
|
//- Templated implementation for lookupClass()
|
||||||
template<class MatchPredicate>
|
template<class MatchPredicate1, class MatchPredicate2>
|
||||||
static IOobjectList lookupClassImpl
|
static IOobjectList lookupClassImpl
|
||||||
(
|
(
|
||||||
const IOobjectList& list,
|
const IOobjectList& list,
|
||||||
const word& matchClass,
|
const MatchPredicate1& matchClass,
|
||||||
const MatchPredicate& matchName
|
const MatchPredicate2& matchName
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@ -168,26 +172,25 @@ public:
|
|||||||
bool remove(const IOobject& io);
|
bool remove(const IOobject& io);
|
||||||
|
|
||||||
|
|
||||||
// Lookup single
|
// Lookup single item
|
||||||
|
|
||||||
//- Lookup an object by name
|
//- Locate an object by name
|
||||||
// \return IOobject ptr if found else nullptr
|
// \return IOobject ptr if found else nullptr
|
||||||
IOobject* findObject(const word& objName) const;
|
IOobject* findObject(const word& objName) const;
|
||||||
|
|
||||||
|
|
||||||
// Lookup multiple
|
// Lookup multiple items
|
||||||
|
|
||||||
//- The list of all IOobjects with matching names
|
//- The list of all IOobjects that have a matching object name.
|
||||||
IOobjectList lookup(const wordRe& matchName) const;
|
template<class MatchPredicate>
|
||||||
|
IOobjectList lookup(const MatchPredicate& matchName) const;
|
||||||
|
|
||||||
//- The list of all IOobjects with matching names
|
//- The list of all IOobjects with the given headerClassName
|
||||||
IOobjectList lookup(const wordRes& matchName) const;
|
IOobjectList lookupClass(const char* clsName) const;
|
||||||
|
|
||||||
//- The list of all IOobjects with matching names
|
//- The list of all IOobjects with matching headerClassName
|
||||||
IOobjectList lookup(const wordHashSet& matchName) const;
|
template<class MatchPredicate>
|
||||||
|
IOobjectList lookupClass(const MatchPredicate& matchClass) const;
|
||||||
//- The list of all IOobjects with the given class name
|
|
||||||
IOobjectList lookupClass(const word& clsName) const;
|
|
||||||
|
|
||||||
|
|
||||||
// Summary of classes
|
// Summary of classes
|
||||||
@ -265,16 +268,9 @@ public:
|
|||||||
HashTable<wordHashSet> classes() const;
|
HashTable<wordHashSet> classes() const;
|
||||||
|
|
||||||
//- A summary hash of classes used and their associated object names,
|
//- A summary hash of classes used and their associated object names,
|
||||||
//- restricted to objects with names that satisfy the input matcher
|
//- restricted to objects that have a matching object name.
|
||||||
HashTable<wordHashSet> classes(const wordRe& matchName) const;
|
template<class MatchPredicate>
|
||||||
|
HashTable<wordHashSet> classes(const MatchPredicate& matchName) const;
|
||||||
//- A summary hash of classes used and their associated object names,
|
|
||||||
//- restricted to objects with names that satisfy the input matcher
|
|
||||||
HashTable<wordHashSet> classes(const wordRes& matchName) const;
|
|
||||||
|
|
||||||
//- A summary hash of classes used and their associated object names,
|
|
||||||
//- restricted to objects with names that satisfy the input matcher
|
|
||||||
HashTable<wordHashSet> classes(const wordHashSet& matchName) const;
|
|
||||||
|
|
||||||
|
|
||||||
// Summary of names
|
// Summary of names
|
||||||
@ -282,62 +278,37 @@ public:
|
|||||||
//- The names of the IOobjects
|
//- The names of the IOobjects
|
||||||
wordList names() const;
|
wordList names() const;
|
||||||
|
|
||||||
|
//- The names of the IOobjects.
|
||||||
|
// With syncPar = true, sorts the names and triggers FatalError
|
||||||
|
// if the names are not consistent on all processors.
|
||||||
|
wordList names(const bool syncPar) const;
|
||||||
|
|
||||||
//- The names of IOobjects with the given class
|
//- The names of IOobjects with the given class
|
||||||
wordList names(const word& clsName) const;
|
wordList names(const word& clsName) const;
|
||||||
|
|
||||||
//- The names of IOobjects with the given class that also
|
//- The names of the IOobjects with the given headerClassName
|
||||||
//- have a name satisfying the input matcher
|
// With syncPar = true, sorts the names and triggers FatalError
|
||||||
wordList names(const word& clsName, const wordRe& matchName) const;
|
// if the names are not consistent on all processors.
|
||||||
|
|
||||||
//- The names of IOobjects with the given class that also
|
|
||||||
//- have a name satisfying the input matcher
|
|
||||||
wordList names(const word& clsName, const wordRes& matchName) const;
|
|
||||||
|
|
||||||
//- The names of IOobjects with the given class that also
|
|
||||||
//- have a name satisfying the input matcher
|
|
||||||
wordList names(const word& clsName, const wordHashSet& matchName) const;
|
|
||||||
|
|
||||||
|
|
||||||
//- A sorted list of names of the IOobjects.
|
|
||||||
// With syncPar = true, triggers FatalError if the names are
|
|
||||||
// not consistent on all processors.
|
|
||||||
wordList names(const bool syncPar) const;
|
|
||||||
|
|
||||||
//- A sorted list of names of the IOobjects
|
|
||||||
// With syncPar = true, triggers FatalError if the names are
|
|
||||||
// not consistent on all processors.
|
|
||||||
wordList names(const word& clsName, const bool syncPar) const;
|
wordList names(const word& clsName, const bool syncPar) const;
|
||||||
|
|
||||||
//- The sorted names of IOobjects with the given class name that also
|
//- The names of IOobjects with the given headerClassName
|
||||||
//- have a name satisfying the input matcher
|
//- that also have a matching object name.
|
||||||
// With syncPar = true, triggers FatalError if the names are
|
template<class MatchPredicate>
|
||||||
// not consistent on all processors.
|
|
||||||
wordList names
|
wordList names
|
||||||
(
|
(
|
||||||
const word& clsName,
|
const word& clsName,
|
||||||
const wordRe& matchName,
|
const MatchPredicate& matchName
|
||||||
const bool syncPar
|
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- The sorted names of IOobjects with the given class name that also
|
//- The names of the IOobjects with the given headerClassName
|
||||||
//- have a name satisfying the input matcher
|
//- that also have a matching object name.
|
||||||
// With syncPar = true, triggers FatalError if the names are
|
// With syncPar = true, sorts the names and triggers FatalError
|
||||||
// not consistent on all processors.
|
// if the names are not consistent on all processors.
|
||||||
|
template<class MatchPredicate>
|
||||||
wordList names
|
wordList names
|
||||||
(
|
(
|
||||||
const word& clsName,
|
const word& clsName,
|
||||||
const wordRes& matchName,
|
const MatchPredicate& matchName,
|
||||||
const bool syncPar
|
|
||||||
) const;
|
|
||||||
|
|
||||||
//- The sorted names of IOobjects with the given class that also
|
|
||||||
//- have a name satisfying the input matcher
|
|
||||||
// With syncPar = true, triggers FatalError if the names are
|
|
||||||
// not consistent on all processors.
|
|
||||||
wordList names
|
|
||||||
(
|
|
||||||
const word& cls,
|
|
||||||
const wordHashSet& matchName,
|
|
||||||
const bool syncPar
|
const bool syncPar
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
@ -347,31 +318,38 @@ public:
|
|||||||
//- The sorted names of the IOobjects
|
//- The sorted names of the IOobjects
|
||||||
wordList sortedNames() const;
|
wordList sortedNames() const;
|
||||||
|
|
||||||
//- The sorted names of IOobjects with the given class
|
//- The sorted names of the IOobjects
|
||||||
|
// With syncPar = true, a FatalError is
|
||||||
|
// triggered if the names are not consistent on all processors.
|
||||||
|
wordList sortedNames(const bool syncPar) const;
|
||||||
|
|
||||||
|
//- The sorted names of IOobjects with the given headerClassName
|
||||||
wordList sortedNames(const word& clsName) const;
|
wordList sortedNames(const word& clsName) const;
|
||||||
|
|
||||||
//- The sorted names of IOobjects with the given class that also
|
//- The sorted names of the IOobjects with the given headerClassName
|
||||||
//- have a name satisfying the input matcher
|
// With syncPar = true, sorts the names and triggers FatalError
|
||||||
|
// if the names are not consistent on all processors.
|
||||||
|
wordList sortedNames(const word& clsName, const bool syncPar) const;
|
||||||
|
|
||||||
|
//- The sorted names of IOobjects with the given headerClassName
|
||||||
|
//- that also have a matching object name.
|
||||||
|
template<class MatchPredicate>
|
||||||
wordList sortedNames
|
wordList sortedNames
|
||||||
(
|
(
|
||||||
const word& clsName,
|
const word& clsName,
|
||||||
const wordRe& matchName
|
const MatchPredicate& matchName
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- The sorted names of IOobjects with the given class that also
|
//- The sorted names of the IOobjects with the given headerClassName
|
||||||
//- have a name satisfying the input matcher
|
//- that also have a matching object name.
|
||||||
|
// With syncPar = true, sorts the names and triggers FatalError
|
||||||
|
// if the names are not consistent on all processors.
|
||||||
|
template<class MatchPredicate>
|
||||||
wordList sortedNames
|
wordList sortedNames
|
||||||
(
|
(
|
||||||
const word& clsName,
|
const word& clsName,
|
||||||
const wordRes& matchName
|
const MatchPredicate& matchName,
|
||||||
) const;
|
const bool syncPar
|
||||||
|
|
||||||
//- The sorted names of IOobjects with the given class that also
|
|
||||||
//- have a name satisfying the input matcher
|
|
||||||
wordList sortedNames
|
|
||||||
(
|
|
||||||
const word& clsName,
|
|
||||||
const wordHashSet& matchName
|
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
@ -386,8 +364,16 @@ public:
|
|||||||
|
|
||||||
// Housekeeping
|
// Housekeeping
|
||||||
|
|
||||||
//- Deprecated(2018-11) Lookup an object by name
|
//- Deprecated(2018-11) Locate an object by name (c-string).
|
||||||
// \return IOobject ptr if found else nullptr
|
//- Disambiguated from multiple-lookup version by calling parameter.
|
||||||
|
// \deprecated(2018-11) use findObject() for non-ambiguous resolution
|
||||||
|
IOobject* lookup(const char* objName) const
|
||||||
|
{
|
||||||
|
return findObject(objName);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Deprecated(2018-11) Locate an object by name (const word&).
|
||||||
|
//- Disambiguated from multiple-lookup version by calling parameter.
|
||||||
// \deprecated(2018-11) use findObject() for non-ambiguous resolution
|
// \deprecated(2018-11) use findObject() for non-ambiguous resolution
|
||||||
IOobject* lookup(const word& objName) const
|
IOobject* lookup(const word& objName) const
|
||||||
{
|
{
|
||||||
|
|||||||
@ -24,6 +24,7 @@ License
|
|||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "IOobjectList.H"
|
#include "IOobjectList.H"
|
||||||
|
#include "predicates.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -55,13 +56,14 @@ Foam::HashTable<Foam::wordHashSet> Foam::IOobjectList::classesImpl
|
|||||||
|
|
||||||
|
|
||||||
// Templated implementation for names(), sortedNames()
|
// Templated implementation for names(), sortedNames()
|
||||||
template<class MatchPredicate>
|
template<class MatchPredicate1, class MatchPredicate2>
|
||||||
Foam::wordList Foam::IOobjectList::namesImpl
|
Foam::wordList Foam::IOobjectList::namesImpl
|
||||||
(
|
(
|
||||||
const IOobjectList& list,
|
const IOobjectList& list,
|
||||||
const word& matchClass,
|
const MatchPredicate1& matchClass,
|
||||||
const MatchPredicate& matchName,
|
const MatchPredicate2& matchName,
|
||||||
const bool doSort
|
const bool doSort,
|
||||||
|
const bool syncPar
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
wordList objNames(list.size());
|
wordList objNames(list.size());
|
||||||
@ -86,6 +88,8 @@ Foam::wordList Foam::IOobjectList::namesImpl
|
|||||||
Foam::sort(objNames);
|
Foam::sort(objNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkNames(objNames, syncPar);
|
||||||
|
|
||||||
return objNames;
|
return objNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,12 +125,12 @@ Foam::IOobjectList Foam::IOobjectList::lookupImpl
|
|||||||
|
|
||||||
|
|
||||||
// Templated implementation for lookupClass()
|
// Templated implementation for lookupClass()
|
||||||
template<class MatchPredicate>
|
template<class MatchPredicate1, class MatchPredicate2>
|
||||||
Foam::IOobjectList Foam::IOobjectList::lookupClassImpl
|
Foam::IOobjectList Foam::IOobjectList::lookupClassImpl
|
||||||
(
|
(
|
||||||
const IOobjectList& list,
|
const IOobjectList& list,
|
||||||
const word& matchClass,
|
const MatchPredicate1& matchClass,
|
||||||
const MatchPredicate& matchName
|
const MatchPredicate2& matchName
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
IOobjectList results(list.size());
|
IOobjectList results(list.size());
|
||||||
@ -151,4 +155,87 @@ Foam::IOobjectList Foam::IOobjectList::lookupClassImpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class MatchPredicate>
|
||||||
|
Foam::IOobjectList Foam::IOobjectList::lookup
|
||||||
|
(
|
||||||
|
const MatchPredicate& matchName
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return lookupImpl(*this, matchName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class MatchPredicate>
|
||||||
|
Foam::IOobjectList Foam::IOobjectList::lookupClass
|
||||||
|
(
|
||||||
|
const MatchPredicate& matchClass
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return lookupClassImpl(*this, matchClass, predicates::always());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class MatchPredicate>
|
||||||
|
Foam::HashTable<Foam::wordHashSet>
|
||||||
|
Foam::IOobjectList::classes
|
||||||
|
(
|
||||||
|
const MatchPredicate& matchName
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return classesImpl(*this, matchName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class MatchPredicate>
|
||||||
|
Foam::wordList Foam::IOobjectList::names
|
||||||
|
(
|
||||||
|
const word& clsName,
|
||||||
|
const MatchPredicate& matchName
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
// sort/sync: false, false
|
||||||
|
return namesImpl(*this, clsName, matchName, false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class MatchPredicate>
|
||||||
|
Foam::wordList Foam::IOobjectList::names
|
||||||
|
(
|
||||||
|
const word& clsName,
|
||||||
|
const MatchPredicate& matchName,
|
||||||
|
const bool syncPar
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
// sort: false
|
||||||
|
return namesImpl(*this, clsName, matchName, false, syncPar);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class MatchPredicate>
|
||||||
|
Foam::wordList Foam::IOobjectList::sortedNames
|
||||||
|
(
|
||||||
|
const word& clsName,
|
||||||
|
const MatchPredicate& matchName
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
// sort/sync: true, false
|
||||||
|
return namesImpl(*this, clsName, matchName, true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class MatchPredicate>
|
||||||
|
Foam::wordList Foam::IOobjectList::sortedNames
|
||||||
|
(
|
||||||
|
const word& clsName,
|
||||||
|
const MatchPredicate& matchName,
|
||||||
|
const bool syncPar
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
// sort: true
|
||||||
|
return namesImpl(*this, clsName, matchName, true, syncPar);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
Reference in New Issue
Block a user