FlatOutput.H
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 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::FlatOutput
28 
29 Description
30  Simple output adapter for list output on a single line.
31  The backend type must support a two-argument \c writeList() method.
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef FlatOutput_H
36 #define FlatOutput_H
37 
38 #include "Ostream.H"
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 
45 // Forward declaration of friend functions and operators
46 template<class Container> class FlatOutput;
47 template<class Container>
49 
50 
51 /*---------------------------------------------------------------------------*\
52  Class FlatOutput Declaration
53 \*---------------------------------------------------------------------------*/
54 
55 template<class Container>
56 class FlatOutput
57 {
58  const Container& ref_;
59  const label len_;
60 
61 public:
62 
63  //- Construct from components
64  inline FlatOutput(const Container& obj, label len)
65  :
66  ref_(obj),
67  len_(len)
68  {}
69 
70  //- Ostream operator
71  inline friend Ostream& operator<<
72  (
73  Ostream& os,
74  const FlatOutput<Container>& wrapped
75  )
76  {
77  return wrapped.ref_.writeList(os, wrapped.len_);
78  }
79 };
80 
81 
82 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
83 
84 //- Global flatOutput function
85 template<class Container>
86 FlatOutput<Container> flatOutput(const Container& obj, label len=0)
87 {
88  return FlatOutput<Container>(obj, len);
89 }
90 
91 
92 } // End namespace Foam
93 
94 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
95 
96 #endif
97 
98 // ************************************************************************* //
Foam::FlatOutput::FlatOutput
FlatOutput(const Container &obj, label len)
Construct from components.
Definition: FlatOutput.H:63
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Ostream.H
Foam::flatOutput
FlatOutput< Container > flatOutput(const Container &obj, label len=0)
Global flatOutput function.
Definition: FlatOutput.H:85
Foam::FlatOutput
Simple output adapter for list output on a single line. The backend type must support a two-argument ...
Definition: FlatOutput.H:45
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &)
Definition: boundaryPatch.C:102