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-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 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 private:
121 
122  // Private Member Functions
123 
124  //- Disallow default bitwise copy construct
126 
127  //- Disallow default bitwise assignment
128  void operator=(const writeObjectsBase&);
129 
130 
131 public:
132 
133  // Constructors
134 
135  //- Construct from objectRegistry and inheriting function object
137  (
138  const objectRegistry& obr,
139  const Switch& logRef
140  );
141 
142 
143  //- Destructor
144  virtual ~writeObjectsBase();
145 
146 
147  // Member Functions
148 
149  //- Return const access to the object names requested to be written
150  const wordReList& writeObjectNames() const;
151 
152  //- Read the list of objects to be written
153  virtual bool read(const dictionary&);
154 
155  //- Write function
156  virtual bool write();
157 };
158 
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
162 } // End namespace functionObjects
163 } // End namespace Foam
164 
165 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166 
167 #endif
168 
169 // ************************************************************************* //
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:137
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.
Definition: Switch.H:60
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:65
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.