threadedCollatedOFstream.C
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) 2017-2018 OpenFOAM Foundation
9  Copyright (C) 2020-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
30 #include "decomposedBlockData.H"
31 #include "OFstreamCollator.H"
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
36 (
38  const fileName& pathName,
39  IOstreamOption streamOpt,
40  const bool useThread
41 )
42 :
43  OStringStream(streamOpt),
44  writer_(writer),
45  pathName_(pathName),
46  compression_(streamOpt.compression()),
47  useThread_(useThread),
48  headerEntries_()
49 {}
50 
51 
52 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
53 
55 {
56  writer_.write
57  (
58  decomposedBlockData::typeName,
59  pathName_,
60  str(),
61  IOstreamOption(IOstream::BINARY, version(), compression_),
62  false, // append=false
63  useThread_,
64  headerEntries_
65  );
66 }
67 
68 
69 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
70 
72 {
73  headerEntries_ = dict;
74 }
75 
76 
77 // ************************************************************************* //
Foam::threadedCollatedOFstream::setHeaderEntries
void setHeaderEntries(const dictionary &dict)
Define the header entries for the data block(s)
Definition: threadedCollatedOFstream.C:71
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Foam::IOstreamOption::IOstreamOption
constexpr IOstreamOption(streamFormat fmt=streamFormat::ASCII, compressionType comp=compressionType::UNCOMPRESSED) noexcept
Definition: IOstreamOption.H:193
Foam::threadedCollatedOFstream::threadedCollatedOFstream
threadedCollatedOFstream(OFstreamCollator &writer, const fileName &pathname, IOstreamOption streamOpt=IOstreamOption(), const bool useThread=true)
Construct and set stream status.
Definition: threadedCollatedOFstream.C:36
Foam::threadedCollatedOFstream::~threadedCollatedOFstream
~threadedCollatedOFstream()
Destructor.
Definition: threadedCollatedOFstream.C:54
Foam::IOstreamOption
The IOstreamOption is a simple container for options an IOstream can normally have.
Definition: IOstreamOption.H:63
Foam::IOstreamOption::version
versionNumber version() const noexcept
Get the stream version.
Definition: IOstreamOption.H:338
dict
dictionary dict
Definition: searchingEngine.H:14
threadedCollatedOFstream.H
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::writer
Base class for graphics format writing. Entry points are.
Definition: writer.H:81
Foam::OFstreamCollator
Threaded file writer.
Definition: OFstreamCollator.H:70
Foam::Detail::StringStreamAllocator< std::ostringstream >::str
Foam::string str() const
Get the string - as Foam::string rather than std::string.
Definition: StringStream.H:88
Foam::IOstreamOption::BINARY
"binary"
Definition: IOstreamOption.H:73
decomposedBlockData.H
Foam::OStringStream
Output to string buffer, using a OSstream. Always UNCOMPRESSED.
Definition: StringStream.H:227
Foam::OFstreamCollator::write
bool write(const word &objectType, const fileName &, const string &data, IOstreamOption streamOpt, const bool append, const bool useThread=true, const dictionary &headerEntries=dictionary::null)
Write file with contents.
Definition: OFstreamCollator.C:346
Foam::IOstreamOption::compression
compressionType compression() const noexcept
Get the stream compression.
Definition: IOstreamOption.H:312
OFstreamCollator.H