writeLocalObjects.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "writeLocalObjects.H"
27 #include "stringListOps.H"
28 #include "dictionary.H"
29 
30 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
31 
33 (
34  const word& name
35 )
36 {
39 }
40 
41 
43 (
44  const wordList& names
45 )
46 {
47  localObjectNames_.clear();
48  localObjectNames_.append(names);
49 }
50 
51 
53 {
54  wordList names
55  (
56  subsetStrings(wordReListMatcher(writeObjectNames_), localObjectNames_)
57  );
58 
59  return names;
60 }
61 
62 
63 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
64 
66 (
67  const objectRegistry& obr,
68  const Switch& log
69 )
70 :
71  writeObjectsBase(obr, log),
72  localObjectNames_()
73 {}
74 
75 
76 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
77 
79 {}
80 
81 
82 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
83 
84 const Foam::wordList&
86 {
87  return localObjectNames_;
88 }
89 
90 
92 {
93  if (dict.found("objects"))
94  {
96  }
97  else
98  {
99  resetWriteObjectName(wordRe(".*", wordRe::compOption::detect));
100  }
101 
102  return true;
103 }
104 
105 
106 // ************************************************************************* //
void append(const T &)
Append an element at the end of the list.
Definition: ListI.H:178
void clear()
Clear the list, i.e. set size to zero.
Definition: ListI.H:125
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:61
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Calculates the natural logarithm of the specified scalar field.
Definition: log.H:106
const wordList & localObjectNames() const
Return const access to the local object names.
wordList localObjectNames_
Object names that are handled on behalf of the inheritor.
virtual wordList objectNames()
Get the list of field names to be written.
void resetLocalObjectNames(const wordList &names)
Reset the list of local object names from a wordList.
writeLocalObjects(const objectRegistry &obr, const Switch &logRef=logFalse)
Construct from objectRegistry and inheriting function object.
void resetLocalObjectName(const word &name)
Reset the list of local object names from a single word.
virtual bool read(const dictionary &)
Read the list of objects to be written.
FunctionObject base class for writing a list of objects registered to the database,...
virtual bool read(const dictionary &)
Read the list of objects to be written.
Registry of regIOobjects.
A wrapper for matching a List of wordRe.
A wordRe is a word, but can also have a regular expression for matching words.
Definition: wordRe.H:77
@ detect
detect if the string contains meta-characters
A class for handling words, derived from string.
Definition: word.H:62
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
StringListType subsetStrings(const regExp &re, const StringListType &lst, const bool invert=false)
Extract elements of StringList when regular expression matches.
dictionary dict
Operations on lists of strings.