OpenFOAM logo
Open Source CFD Toolkit

prefixOSstream.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2005 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     prefixOSstream
00027 
00028 Description
00029     Version of OSstream which prints a prefix on each line.
00030     This is useful for running in parallel as it allows the processor number
00031     to be automatically preprended to each message line.
00032 
00033 SourceFiles
00034     prefixOSwrite.C
00035     prefixOSprint.C
00036 
00037 \*---------------------------------------------------------------------------*/
00038 
00039 #ifndef prefixOSstream_H
00040 #define prefixOSstream_H
00041 
00042 #include "OSstream.H"
00043 
00044 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00045 
00046 namespace Foam
00047 {
00048 
00049 /*---------------------------------------------------------------------------*\
00050                            Class prefixOSstream Declaration
00051 \*---------------------------------------------------------------------------*/
00052 
00053 class prefixOSstream
00054 :
00055     public OSstream
00056 {
00057     // Private data
00058 
00059         bool printPrefix_;
00060         string prefix_;
00061 
00062 
00063     // Private member functions
00064 
00065         inline void checkWritePrefix();
00066 
00067 
00068 public:
00069 
00070     // Constructors
00071 
00072         //- Set stream status
00073         prefixOSstream
00074         (
00075             ostream& os,
00076             const string& name,
00077             streamFormat format=ASCII,
00078             versionNumber version=currentVersion,
00079             compressionType compression=UNCOMPRESSED
00080         );
00081 
00082 
00083     // Member functions
00084 
00085         // Enquiry
00086 
00087             //- Return the prefix of the stream
00088             const string& prefix() const
00089             {
00090                 return prefix_;
00091             }
00092 
00093             //- Return non-const access to the prefix of the stream
00094             string& prefix()
00095             {
00096                 return prefix_;
00097             }
00098 
00099 
00100         // Write functions
00101 
00102             //- Write next token to stream
00103             virtual Ostream& write(const token&);
00104 
00105             //- Write character
00106             virtual Ostream& write(const char);
00107 
00108             //- Write character string
00109             virtual Ostream& write(const char*);
00110 
00111             //- Write word
00112             virtual Ostream& write(const word&);
00113 
00114             //- Write string
00115             virtual Ostream& write(const string&);
00116 
00117             //- Write label
00118             virtual Ostream& write(const label);
00119 
00120             //- Write floatScalar
00121             virtual Ostream& write(const floatScalar);
00122 
00123             //- Write doubleScalar
00124             virtual Ostream& write(const doubleScalar);
00125 
00126             //- Write binary block
00127             virtual Ostream& write(const char*, std::streamsize);
00128 
00129             //- Add indentation characters
00130             virtual void indent();
00131 
00132 
00133         // Print
00134 
00135             //- Print description of IOstream to Ostream
00136             virtual void print(Ostream&) const;
00137 };
00138 
00139 
00140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00141 
00142 } // End namespace Foam
00143 
00144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00145 
00146 #endif
00147 
00148 // ************************************************************************* //
For further information go to www.openfoam.org