FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 Class
00025     Foam::prefixOSstream
00026 
00027 Description
00028     Version of OSstream which prints a prefix on each line.
00029 
00030     This is useful for running in parallel as it allows the processor number
00031     to be automatically prepended to each message line.
00032 
00033 SourceFiles
00034     prefixOSstream.C
00035 
00036 \*---------------------------------------------------------------------------*/
00037 
00038 #ifndef prefixOSstream_H
00039 #define prefixOSstream_H
00040 
00041 #include <OpenFOAM/OSstream.H>
00042 
00043 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00044 
00045 namespace Foam
00046 {
00047 
00048 /*---------------------------------------------------------------------------*\
00049                            Class prefixOSstream Declaration
00050 \*---------------------------------------------------------------------------*/
00051 
00052 class prefixOSstream
00053 :
00054     public OSstream
00055 {
00056     // Private data
00057 
00058         bool printPrefix_;
00059         string prefix_;
00060 
00061 
00062     // Private member functions
00063 
00064         inline void checkWritePrefix();
00065 
00066 
00067 public:
00068 
00069     // Constructors
00070 
00071         //- Set stream status
00072         prefixOSstream
00073         (
00074             ostream& os,
00075             const string& name,
00076             streamFormat format=ASCII,
00077             versionNumber version=currentVersion,
00078             compressionType compression=UNCOMPRESSED
00079         );
00080 
00081 
00082     // Member functions
00083 
00084         // Enquiry
00085 
00086             //- Return the prefix of the stream
00087             const string& prefix() const
00088             {
00089                 return prefix_;
00090             }
00091 
00092             //- Return non-const access to the prefix of the stream
00093             string& prefix()
00094             {
00095                 return prefix_;
00096             }
00097 
00098 
00099         // Write functions
00100 
00101             //- Write next token to stream
00102             virtual Ostream& write(const token&);
00103 
00104             //- Write character
00105             virtual Ostream& write(const char);
00106 
00107             //- Write character string
00108             virtual Ostream& write(const char*);
00109 
00110             //- Write word
00111             virtual Ostream& write(const word&);
00112 
00113             //- Write string
00114             virtual Ostream& write(const string&);
00115 
00116             //- Write std::string surrounded by quotes.
00117             //  Optional write without quotes.
00118             virtual Ostream& writeQuoted
00119             (
00120                 const std::string&,
00121                 const bool quoted=true
00122             );
00123 
00124             //- Write label
00125             virtual Ostream& write(const label);
00126 
00127             //- Write floatScalar
00128             virtual Ostream& write(const floatScalar);
00129 
00130             //- Write doubleScalar
00131             virtual Ostream& write(const doubleScalar);
00132 
00133             //- Write binary block
00134             virtual Ostream& write(const char*, std::streamsize);
00135 
00136             //- Add indentation characters
00137             virtual void indent();
00138 
00139 
00140         // Print
00141 
00142             //- Print description of IOstream to Ostream
00143             virtual void print(Ostream&) const;
00144 };
00145 
00146 
00147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00148 
00149 } // End namespace Foam
00150 
00151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00152 
00153 #endif
00154 
00155 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines