initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / db / IOstreams / Pstreams / OPstream.H
blob6db9a827b11d4c5ce554231de07d509da7ca7ac4
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::OPstream
28 Description
29     Output inter-processor communications stream.
31 SourceFiles
32     OPstream.C
34 \*---------------------------------------------------------------------------*/
36 #include "Pstream.H"
38 #ifndef OPstream_H
39 #define OPstream_H
41 #include "Ostream.H"
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 namespace Foam
48 /*---------------------------------------------------------------------------*\
49                           Class OPstream Declaration
50 \*---------------------------------------------------------------------------*/
52 class OPstream
54     public Pstream,
55     public Ostream
57     // Private data
59         int toProcNo_;
62     // Private member functions
64         //- Write a T to the transfer buffer
65         template<class T>
66         inline void writeToBuffer(const T&);
68         //- Write a char to the transfer buffer
69         inline void writeToBuffer(const char&);
71         //- Write data to the transfer buffer
72         inline void writeToBuffer(const void* data, size_t count, size_t align);
75 public:
77     // Constructors
79         //- Construct given process index to send to and optional buffer size,
80         //  write format and IO version
81         OPstream
82         (
83             const commsTypes commsType,
84             const int toProcNo,
85             const label bufSize = 0,
86             streamFormat format=BINARY,
87             versionNumber version=currentVersion
88         );
91     // Destructor
93         ~OPstream();
96     // Member functions
98         // Inquiry
100             //- Return flags of output stream
101             ios_base::fmtflags flags() const
102             {
103                 return ios_base::fmtflags(0);
104             }
107         // Write functions
109             //- Write given buffer to given processor
110             static bool write
111             (
112                 const commsTypes commsType,
113                 const int toProcNo,
114                 const char* buf,
115                 const std::streamsize bufSize
116             );
118             //- Non-blocking writes: wait until all have finished.
119             static void waitRequests();
121             //- Non-blocking writes: has request i finished?
122             static bool finishedRequest(const label i);
124             //- Write next token to stream
125             Ostream& write(const token&);
127             //- Write character
128             Ostream& write(const char);
130             //- Write character string
131             Ostream& write(const char*);
133             //- Write word
134             Ostream& write(const word&);
136             //- Write string
137             Ostream& write(const string&);
139             //- Write std::string surrounded by quotes.
140             //  Optional write without quotes.
141             Ostream& writeQuoted
142             (
143                 const std::string&,
144                 const bool quoted=true
145             );
147             //- Write label
148             Ostream& write(const label);
150             //- Write floatScalar
151             Ostream& write(const floatScalar);
153             //- Write doubleScalar
154             Ostream& write(const doubleScalar);
156             //- Write binary block
157             Ostream& write(const char*, std::streamsize);
159             //- Add indentation characters
160             void indent()
161             {}
164         // Stream state functions
166             //- Flush stream
167             void flush()
168             {}
170             //- Add newline and flush stream
171             void endl()
172             {}
174             //- Get width of output field
175             int width() const
176             {
177                 return 0;
178             }
180             //- Set width of output field (and return old width)
181             int width(const int)
182             {
183                  return 0;
184             }
186             //- Get precision of output field
187             int precision() const
188             {
189                  return 0;
190             }
192             //- Set precision of output field (and return old precision)
193             int precision(const int)
194             {
195                  return 0;
196             }
199         // Edit
201             //- Set flags of stream
202             ios_base::fmtflags flags(const ios_base::fmtflags)
203             {
204                 return ios_base::fmtflags(0);
205             }
208         // Print
210             //- Print description of IOstream to Ostream
211             void print(Ostream&) const;
215 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 } // End namespace Foam
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
221 #endif
223 // ************************************************************************* //