initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / OpenFOAM / db / IOstreams / Pstreams / OPstream.H
blob6041ba202a5caa6773a5a98677d4f11572cf22d2
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 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     OPstreamI.H
33     OPwrite.C
35 \*---------------------------------------------------------------------------*/
37 #include "Pstream.H"
39 #ifndef OPstream_H
40 #define OPstream_H
42 #include "Ostream.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 namespace Foam
49 /*---------------------------------------------------------------------------*\
50                            Class OPstream Declaration
51 \*---------------------------------------------------------------------------*/
53 class OPstream
55     public Pstream,
56     public Ostream
58     // Private data
60         int toProcNo_;
63     // Private member functions
65         //- Write a T to the transfer buffer
66         template<class T>
67         inline void writeToBuffer(const T&);
69         //- Write a char to the transfer buffer
70         inline void writeToBuffer(const char&);
72         //- Write data to the transfer buffer
73         inline void writeToBuffer(const void* data, size_t count);
76 public:
78     // Constructors
80         //- Construct given process index to send to and optional buffer size,
81         //  write format and IO version
82         OPstream
83         (
84             const commsTypes commsType,
85             const int toProcNo,
86             const label bufSize = 0,
87             streamFormat format=BINARY,
88             versionNumber version=currentVersion
89         );
92     // Destructor
94         ~OPstream();
97     // Member functions
99         // Inquiry
101             //- Return flags of output stream
102             ios_base::fmtflags flags() const
103             {
104                 return ios_base::fmtflags(0);
105             }
108         // Write functions
110             //- Write given buffer to given processor
111             static bool write
112             (
113                 const commsTypes commsType,
114                 const int toProcNo,
115                 const char* buf,
116                 const std::streamsize bufSize
117             );
119             //- Non-blocking writes: wait until all have finished.
120             static void waitRequests();
122             //- Non-blocking writes: has request i finished?
123             static bool finishedRequest(const label i);
125             //- Write next token to stream
126             Ostream& write(const token&);
128             //- Write character
129             Ostream& write(const char);
131             //- Write character string
132             Ostream& write(const char*);
134             //- Write word
135             Ostream& write(const word&);
137             //- Write string
138             Ostream& write(const string&);
140             //- Write label
141             Ostream& write(const label);
143             //- Write floatScalar
144             Ostream& write(const floatScalar);
146             //- Write doubleScalar
147             Ostream& write(const doubleScalar);
149             //- Write binary block
150             Ostream& write(const char*, std::streamsize);
152             //- Add indentation characters
153             void indent()
154             {}
157         // Stream state functions
159             //- Flush stream
160             void flush()
161             {}
163             //- Add '\n' and flush stream
164             void endl()
165             {}
167             //- Get width of output field
168             int width() const
169             {
170                 return 0;
171             }
173             //- Set width of output field (and return old width)
174             int width(const int)
175             {
176                  return 0;
177             }
179             //- Get precision of output field
180             int precision() const
181             {
182                  return 0;
183             }
185             //- Set precision of output field (and return old precision)
186             int precision(const int)
187             {
188                  return 0;
189             }
192         // Edit
194             //- Set flags of stream
195             ios_base::fmtflags flags(const ios_base::fmtflags)
196             {
197                 return ios_base::fmtflags(0);
198             }
201         // Print
203             //- Print description of IOstream to Ostream
204             void print(Ostream&) const;
208 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 } // End namespace Foam
212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 // include inline implementaions
215 #   include "OPstreamI.H"
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 #endif
221 // ************************************************************************* //