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-2019 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 "string.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 
64  //- The output style tuning
65  enum styleType
66  {
67  NONE = 0x00,
68  HEADER = 0x01
69  };
70 
71  //- The output format type
72  formatType fmtType_;
73 
74  //- ASCII write precision
75  mutable unsigned precision_;
76 
77 
78 public:
79 
80  // Constructors
81 
82  //- Construct null - XML insitu ASCII format with default precision
83  inline outputOptions();
84 
85  //- Construct with specified format and default (ASCII) precision
86  // \note This constructor should remain non-explicit.
87  inline outputOptions(enum formatType fmtType);
88 
89  //- Construct with specified format and (ASCII) write precision
90  inline outputOptions(enum formatType fmtType, unsigned prec);
91 
92 
93  // Selectors
94 
95  //- Return new formatter based on the selected output options
96  inline autoPtr<formatter> newFormatter(std::ostream& os) const;
97 
98 
99  // Member Functions
100 
101  // Access
102 
103  //- The output format type
104  inline formatType fmt() const;
105 
106  //- The file extension (legacy or xml) for the given content-type
107  inline word ext(vtk::fileTag contentType) const;
108 
109  //- True if writer uses legacy file format
110  inline bool legacy() const;
111 
112  //- True if writer uses XML file format (non-legacy)
113  inline bool xml() const;
114 
115  //- True if output format uses an append mode
116  inline bool append() const;
117 
118  //- True if output format does not use an append mode
119  inline bool insitu() const;
120 
121  //- True if output format is ASCII
122  inline bool ascii() const;
123 
124  //- Return the ASCII write precision
125  inline unsigned precision() const;
126 
127 
128  // Edit
129 
130  //- Toggle ASCII mode on/off.
131  // In XML append mode, this switches between base64 and raw binary.
132  // In XML inline mode, this switches between ASCII and base64.
133  // In legacy mode, this switches between ASCII and binary.
134  // \return outputOptions for chaining
135  outputOptions& ascii(bool on);
136 
137  //- Toggle append mode on/off.
138  // \return outputOptions for chaining
139  outputOptions& append(bool on);
140 
141  //- Toggle legacy mode on/off.
142  // \return outputOptions for chaining
143  outputOptions& legacy(bool on);
144 
145  //- Set the write precision to be used for new ASCII formatters
146  // \return outputOptions for chaining
147  outputOptions& precision(unsigned prec);
148 
149 
150  // Other
151 
152  //- A text description about the output option selected
153  string description() const;
154 
155 };
156 
157 
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 
160 } // End namespace vtk
161 } // End namespace Foam
162 
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164 
165 #include "foamVtkOutputOptionsI.H"
166 
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 
169 #endif
170 
171 // ************************************************************************* //
Foam::vtk::outputOptions
Encapsulated combinations of output format options. This is primarily useful when defining the output...
Definition: foamVtkOutputOptions.H:59
foamVtkOutput.H
Foam::vtk::outputOptions::description
string description() const
A text description about the output option selected.
Definition: foamVtkOutputOptions.C:172
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::vtk::outputOptions::precision
unsigned precision() const
Return the ASCII write precision.
Definition: foamVtkOutputOptionsI.H:126
Foam::vtk::outputOptions::newFormatter
autoPtr< formatter > newFormatter(std::ostream &os) const
Return new formatter based on the selected output options.
Definition: foamVtkOutputOptionsI.H:63
Foam::vtk::outputOptions::outputOptions
outputOptions()
Construct null - XML insitu ASCII format with default precision.
Definition: foamVtkOutputOptionsI.H:32
Foam::vtk::outputOptions::legacy
bool legacy() const
True if writer uses legacy file format.
Definition: foamVtkOutputOptionsI.H:88
string.H
Foam::vtk::outputOptions::fmt
formatType fmt() const
The output format type.
Definition: foamVtkOutputOptionsI.H:71
Foam::vtk::formatType
formatType
The output format type for file contents.
Definition: foamVtkCore.H:65
Foam::vtk::outputOptions::ascii
bool ascii() const
True if output format is ASCII.
Definition: foamVtkOutputOptionsI.H:120
Foam::vtk::outputOptions::append
bool append() const
True if output format uses an append mode.
Definition: foamVtkOutputOptionsI.H:104
foamVtkOutputOptionsI.H
os
OBJstream os(runTime.globalPath()/outputName)
Foam::vtk::fileTag
fileTag
Some common XML tags for vtk files.
Definition: foamVtkCore.H:113
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::vtk::outputOptions::insitu
bool insitu() const
True if output format does not use an append mode.
Definition: foamVtkOutputOptionsI.H:114
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::vtk::outputOptions::xml
bool xml() const
True if writer uses XML file format (non-legacy)
Definition: foamVtkOutputOptionsI.H:98
Foam::vtk::outputOptions::ext
word ext(vtk::fileTag contentType) const
The file extension (legacy or xml) for the given content-type.
Definition: foamVtkOutputOptionsI.H:77