All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
writeObjectsBase.H
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-2020 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 Class
25  Foam::functionObjects::writeObjectsBase
26 
27 Description
28  FunctionObject base class for writing a list of objects registered to the
29  database, on behalf of the inheriting function object, on when those should
30  be written to disk.
31 
32  FunctionObjects that inherit this class will receive the additional
33  dictionary option \c objects which allows selecting which fields of the
34  inherited function should be written to disk when \c write() is called.
35 
36  Example of function object specification:
37  \verbatim
38  <functionObjectName>
39  {
40  ...
41  objects (obj1 obj2);
42  ...
43  }
44  \endverbatim
45 
46 Usage
47  \table
48  Property | Description | Required | Default value
49  objects | List of objects to be written | yes |
50  regExp | Switch for regular expression support | no | true
51  \endtable
52 
53  Note: Regular expressions can also be used in \c objects.
54 
55 See also
56  Foam::functionObject
57  Foam::functionObjects::writeObjects
58  Foam::functionObjects::writeLocalObjects
59 
60 SourceFiles
61  writeObjectsBase.C
62 
63 \*---------------------------------------------------------------------------*/
64 
65 #ifndef functionObjects_writeObjectsBase_H
66 #define functionObjects_writeObjectsBase_H
67 
68 #include "wordList.H"
69 #include "wordReList.H"
70 #include "Switch.H"
71 
72 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
73 
74 namespace Foam
75 {
76 
77 // Forward declaration of classes
78 class objectRegistry;
79 class regIOobject;
80 class Switch;
81 
82 namespace functionObjects
83 {
84 
85 /*---------------------------------------------------------------------------*\
86  Class writeObjectsBase Declaration
87 \*---------------------------------------------------------------------------*/
88 
89 class writeObjectsBase
90 {
91 
92 protected:
93 
94  // Protected data
95 
96  //- Reference to the region objectRegistry
97  const objectRegistry& writeObr_;
98 
99  //- Reference to the inheriting function object's log variable
100  const Switch& log_;
101 
102  //- Optional switch for regular expression support
103  // Defaults to true
104  Switch regExp_;
105 
106  //- Object names requested by the user to be written
108 
109 
110  // Protected Member Functions
112  //- Reset the list of object names to be written to a single regular
113  // expression
115 
116  //- Reset the list of object names to be written
117  void resetWriteObjectNames(const wordReList& names);
119  //- Get the list of field names to be written
120  virtual wordList objectNames();
122  //- Write the requested registered IO object
123  virtual void writeObject(const regIOobject& obj);
124 
125 
126 public:
127 
128  // Constructors
129 
130  //- Construct from objectRegistry and inheriting function object
132  (
133  const objectRegistry& obr,
134  const Switch& logRef
135  );
136 
137  //- Disallow default bitwise copy construction
138  writeObjectsBase(const writeObjectsBase&) = delete;
139 
140 
141  //- Destructor
142  virtual ~writeObjectsBase();
143 
144 
145  // Member Functions
146 
147  //- Return const access to the object names requested to be written
148  const wordReList& writeObjectNames() const;
149 
150  //- Read the list of objects to be written
151  virtual bool read(const dictionary&);
152 
153  //- Write function
154  virtual bool write();
155 
156 
157  // Member Operators
158 
159  //- Disallow default bitwise assignment
160  void operator=(const writeObjectsBase&) = delete;
161 };
162 
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 } // End namespace functionObjects
167 } // End namespace Foam
168 
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 
171 #endif
172 
173 // ************************************************************************* //
virtual bool write()
Write function.
const objectRegistry & writeObr_
Reference to the region objectRegistry.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none/any.
Definition: Switch.H:60
void operator=(const writeObjectsBase &)=delete
Disallow default bitwise assignment.
void resetWriteObjectNames(const wordReList &names)
Reset the list of object names to be written.
void resetWriteObjectName(const wordRe &name)
Reset the list of object names to be written to a single regular.
const Switch & log_
Reference to the inheriting function object&#39;s log variable.
wordReList writeObjectNames_
Object names requested by the user to be written.
A wordRe is a word, but can also have a regular expression for matching words.
Definition: wordRe.H:74
Switch regExp_
Optional switch for regular expression support.
virtual void writeObject(const regIOobject &obj)
Write the requested registered IO object.
const wordReList & writeObjectNames() const
Return const access to the object names requested to be written.
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
FunctionObject base class for writing a list of objects registered to the database, on behalf of the inheriting function object, on when those should be written to disk.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:52
writeObjectsBase(const objectRegistry &obr, const Switch &logRef)
Construct from objectRegistry and inheriting function object.
virtual wordList objectNames()
Get the list of field names to be written.
Registry of regIOobjects.
virtual bool read(const dictionary &)
Read the list of objects to be written.
Namespace for OpenFOAM.