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-2019 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  \endtable
51 
52  Note: Regular expressions can also be used in \c objects.
53 
54 See also
55  Foam::functionObject
56  Foam::functionObjects::writeObjects
57  Foam::functionObjects::writeLocalObjects
58 
59 SourceFiles
60  writeObjectsBase.C
61 
62 \*---------------------------------------------------------------------------*/
63 
64 #ifndef functionObjects_writeObjectsBase_H
65 #define functionObjects_writeObjectsBase_H
66 
67 #include "wordList.H"
68 #include "wordReList.H"
69 
70 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
71 
72 namespace Foam
73 {
74 
75 // Forward declaration of classes
76 class objectRegistry;
77 class regIOobject;
78 class Switch;
79 
80 namespace functionObjects
81 {
82 
83 /*---------------------------------------------------------------------------*\
84  Class writeObjectsBase Declaration
85 \*---------------------------------------------------------------------------*/
86 
87 class writeObjectsBase
88 {
89 
90 protected:
91 
92  // Protected data
93 
94  //- Reference to the region objectRegistry
95  const objectRegistry& writeObr_;
96 
97  //- Reference to the inheriting function object's log variable
98  const Switch& log_;
99 
100  //- Object names requested by the user to be written
102 
103 
104  // Protected Member Functions
105 
106  //- Reset the list of object names to be written to a single regular
107  // expression
108  void resetWriteObjectName(const wordRe& name);
109 
110  //- Reset the list of object names to be written
111  void resetWriteObjectNames(const wordReList& names);
112 
113  //- Get the list of field names to be written
114  virtual wordList objectNames();
115 
116  //- Write the requested registered IO object
117  virtual void writeObject(const regIOobject& obj);
118 
119 
120 public:
121 
122  // Constructors
123 
124  //- Construct from objectRegistry and inheriting function object
126  (
127  const objectRegistry& obr,
128  const Switch& logRef
129  );
130 
131  //- Disallow default bitwise copy construction
132  writeObjectsBase(const writeObjectsBase&) = delete;
133 
134 
135  //- Destructor
136  virtual ~writeObjectsBase();
137 
138 
139  // Member Functions
140 
141  //- Return const access to the object names requested to be written
142  const wordReList& writeObjectNames() const;
143 
144  //- Read the list of objects to be written
145  virtual bool read(const dictionary&);
146 
147  //- Write function
148  virtual bool write();
149 
150 
151  // Member Operators
152 
153  //- Disallow default bitwise assignment
154  void operator=(const writeObjectsBase&) = delete;
155 };
156 
157 
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 
160 } // End namespace functionObjects
161 } // End namespace Foam
162 
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164 
165 #endif
166 
167 // ************************************************************************* //
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:158
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
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:55
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.