Commit b4c998a2 authored by mark's avatar mark
Browse files

ENH: improve IOobjectList functionality (issue #322)

- provide additional filtering methods on names(), sortedNames()
  For example,

      IOobjectList objects = ...;
      wordReList selection = ...;

      objects.sortedNames(VolFieldType::typeName, selection);
parent 7658aefe
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -27,6 +27,7 @@ License
#include "Time.H"
#include "OSspecific.H"
#include "IOList.H"
#include "stringListOps.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
......@@ -228,7 +229,10 @@ Foam::wordList Foam::IOobjectList::sortedNames() const
}
Foam::wordList Foam::IOobjectList::names(const word& ClassName) const
Foam::wordList Foam::IOobjectList::names
(
const word& ClassName
) const
{
wordList objectNames(size());
......@@ -247,7 +251,34 @@ Foam::wordList Foam::IOobjectList::names(const word& ClassName) const
}
Foam::wordList Foam::IOobjectList::sortedNames(const word& ClassName) const
Foam::wordList Foam::IOobjectList::names
(
const word& ClassName,
const wordRe& matcher
) const
{
wordList objNames = names(ClassName);
return wordList(objNames, findStrings(matcher, objNames));
}
Foam::wordList Foam::IOobjectList::names
(
const word& ClassName,
const wordReList& matcher
) const
{
wordList objNames = names(ClassName);
return wordList(objNames, findStrings(matcher, objNames));
}
Foam::wordList Foam::IOobjectList::sortedNames
(
const word& ClassName
) const
{
wordList sortedLst = names(ClassName);
sort(sortedLst);
......@@ -256,4 +287,30 @@ Foam::wordList Foam::IOobjectList::sortedNames(const word& ClassName) const
}
Foam::wordList Foam::IOobjectList::sortedNames
(
const word& ClassName,
const wordRe& matcher
) const
{
wordList sortedLst = names(ClassName, matcher);
sort(sortedLst);
return sortedLst;
}
Foam::wordList Foam::IOobjectList::sortedNames
(
const word& ClassName,
const wordReList& matcher
) const
{
wordList sortedLst = names(ClassName, matcher);
sort(sortedLst);
return sortedLst;
}
// ************************************************************************* //
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -55,7 +55,7 @@ class IOobjectList
// Private Member Functions
//- Disallow default bitwise assignment
void operator=(const IOobjectList&);
void operator=(const IOobjectList&) = delete;
public:
......@@ -104,17 +104,35 @@ public:
//- Return the list for all IOobjects of a given class
IOobjectList lookupClass(const word& className) const;
//- Return the list of names of the IOobjects
wordList names() const;
//- Return the sorted list of names of the IOobjects
wordList sortedNames() const;
//- A list of names of the IOobjects
wordList names() const;
//- Return the list of names of the IOobjects of given class
//- A list of names of IOobjects of the given class
wordList names(const word& className) const;
//- Return the sorted list of names of the IOobjects of given class
//- A list of names of IOobjects of the given class,
// and that also satisfy the input matcher
wordList names(const word& className, const wordRe&) const;
//- A list of names of IOobjects of the given class,
// and that also satisfy the input matchers
wordList names(const word& className, const wordReList&) const;
//- A sorted list of names of the IOobjects
wordList sortedNames() const;
//- A sorted list of names of IOobjects of given class
wordList sortedNames(const word& className) const;
//- A sorted list of names of IOobjects of the given class,
// and that also satisfy the input matcher
wordList sortedNames(const word& className, const wordRe&) const;
//- A sorted list of names of IOobjects of the given class,
// and that also satisfy the input matchers
wordList sortedNames(const word& className, const wordReList&) const;
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment