InfoProxy.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) 2011 OpenFOAM Foundation
9  Copyright (C) 2023 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::InfoProxy
29 
30 Description
31  A helper class for outputting values to Ostream
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef Foam_InfoProxy_H
36 #define Foam_InfoProxy_H
37 
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 
40 namespace Foam
41 {
42 
43 // Forward Declarations
44 class Ostream;
45 
46 template<class T> class InfoProxy;
47 template<class T> Ostream& operator<<(Ostream&, const InfoProxy<T>&);
48 
49 
50 /*---------------------------------------------------------------------------*\
51  Class InfoProxy Declaration
52 \*---------------------------------------------------------------------------*/
53 
54 template<class T>
55 class InfoProxy
56 {
57 public:
58 
59  // Data
60 
61  //- The captured object reference
62  const T& t_;
63 
64 
65  // Constructors
66 
67  //- Implicit construct from object reference
68  InfoProxy(const T& item) noexcept
69  :
70  t_(item)
71  {}
72 
73 
74  // Member Functions
75 
76  //- Return const reference to the object
77  const T& operator*() const noexcept { return t_; }
78 
79  // // TBD: Dereference const pointer to the object
80  // const T* operator->() const noexcept { return &t_; }
81 
82 
83  // Output Functions
84 
85  //- Output information to stream
86  friend Ostream& operator<< <T> (Ostream&, const InfoProxy<T>&);
87 };
88 
89 
90 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
91 
92 } // End namespace Foam
93 
94 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
95 
96 #endif
97 
98 // ************************************************************************* //
const T & t_
The captured object reference.
Definition: InfoProxy.H:57
const T & operator*() const noexcept
Return const reference to the object.
Definition: InfoProxy.H:76
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const direction noexcept
Definition: Scalar.H:258
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
A helper class for outputting values to Ostream.
Definition: ensightCells.H:43
InfoProxy(const T &item) noexcept
Implicit construct from object reference.
Definition: InfoProxy.H:65
Namespace for OpenFOAM.