foamVtkOutputOptions.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2016-2022 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::vtk::outputOptions
28 
29 Description
30  Encapsulated combinations of output format options.
31  This is primarily useful when defining the output type based on some
32  command-line arguments or dictionary contents.
33  However, it can also be a useful alternative to using the underlying
34  enumeration directly, since this class provides additional methods
35  not possible with an enum.
36 
37 SourceFiles
38  foamVtkOutputOptions.C
39  foamVtkOutputOptionsI.H
40 
41 \*---------------------------------------------------------------------------*/
42 
43 #ifndef Foam_vtk_outputOptions_H
44 #define Foam_vtk_outputOptions_H
45 
46 #include "foamVtkOutput.H"
47 #include "word.H"
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 namespace vtk
54 {
55 
56 /*---------------------------------------------------------------------------*\
57  Class vtk::outputOptions Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 class outputOptions
61 {
62  // Private Member Data
63 
70 
71  //- The output format type
72  vtk::formatType fmtType_;
73 
74  //- ASCII write precision
75  mutable unsigned precision_;
76 
77 
78 public:
79 
80  // Constructors
81 
82  //- Default construct - XML insitu ASCII format with default precision
83  inline outputOptions();
84 
85  //- Construct with specified format and default (ASCII) precision
86  //
87  // \note This constructor should remain non-explicit.
88  inline outputOptions(enum vtk::formatType fmtType);
89 
90  //- Construct with specified format and (ASCII) write precision
91  inline outputOptions(enum vtk::formatType fmtType, unsigned prec);
92 
93 
94  // Selectors
95 
96  //- Return new formatter based on the selected output options
97  inline autoPtr<formatter> newFormatter(std::ostream& os) const;
98 
99 
100  // Member Functions
101 
102  // Access
103 
104  //- The output format type
105  inline vtk::formatType fmt() const noexcept;
106 
107  //- The file extension (legacy or xml) for the given content-type
108  inline word ext(vtk::fileTag contentType) const;
109 
110  //- True if writer uses legacy file format
111  inline bool legacy() const noexcept;
112 
113  //- True if writer uses XML file format (non-legacy)
114  inline bool xml() const noexcept;
115 
116  //- True if output format uses an append mode
117  inline bool append() const noexcept;
118 
119  //- True if output format does not use an append mode
120  inline bool insitu() const noexcept;
121 
122  //- True if output format is ASCII
123  inline bool ascii() const noexcept;
124 
125  //- Return the ASCII write precision
126  inline unsigned precision() const noexcept;
127 
128 
129  // Edit
130 
131  //- Toggle ASCII mode on/off.
132  // In XML append mode, this switches between base64 and raw binary.
133  // In XML inline mode, this switches between ASCII and base64.
134  // In legacy mode, this switches between ASCII and binary.
135  // \return outputOptions for chaining
136  outputOptions& ascii(bool on);
137 
138  //- Toggle append mode on/off.
139  // \return outputOptions for chaining
140  outputOptions& append(bool on);
141 
142  //- Toggle legacy mode on/off.
143  // \return outputOptions for chaining
144  outputOptions& legacy(bool on);
145 
146  //- Set the write precision to be used for new ASCII formatters
147  // \return outputOptions for chaining
148  outputOptions& precision(unsigned prec);
149 
150 
151  // Other
152 
153  //- A text description about the output option selected
154  string description() const;
155 
156 };
157 
158 
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160 
161 } // End namespace vtk
162 } // End namespace Foam
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 #include "foamVtkOutputOptionsI.H"
167 
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 
170 #endif
171 
172 // ************************************************************************* //
autoPtr< formatter > newFormatter(std::ostream &os) const
Return new formatter based on the selected output options.
bool append() const noexcept
True if output format uses an append mode.
string description() const
A text description about the output option selected.
outputOptions()
Default construct - XML insitu ASCII format with default precision.
bool xml() const noexcept
True if writer uses XML file format (non-legacy)
Encapsulated combinations of output format options. This is primarily useful when defining the output...
unsigned precision() const noexcept
Return the ASCII write precision.
A class for handling words, derived from Foam::string.
Definition: word.H:63
formatType
The output format type for file contents.
Definition: foamVtkCore.H:66
bool ascii() const noexcept
True if output format is ASCII.
bool insitu() const noexcept
True if output format does not use an append mode.
const direction noexcept
Definition: Scalar.H:258
vtk::formatType fmt() const noexcept
The output format type.
OBJstream os(runTime.globalPath()/outputName)
fileTag
Some common XML tags for vtk files.
Definition: foamVtkCore.H:122
bool legacy() const noexcept
True if writer uses legacy file format.
word ext(vtk::fileTag contentType) const
The file extension (legacy or xml) for the given content-type.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Namespace for OpenFOAM.