1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
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
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
29 A class for managing temporary objects
34 \*---------------------------------------------------------------------------*/
42 #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
43 # define ConstructFromTmp
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 /*---------------------------------------------------------------------------*\
53 \*---------------------------------------------------------------------------*/
60 //- Flag for whether object is a temporary or a constant object
63 //- Pointer to temporary object
66 // Const reference to constant object
74 //- Store object pointer
75 inline explicit tmp(T* = 0);
77 //- Store object const reference
80 //- Construct copy and increment reference count
81 inline tmp(const tmp<T>&);
86 //- Delete object when reference count == 0
94 //- Return true if this is really a temporary object
95 inline bool isTmp() const;
97 //- Return true if this temporary object empty,
98 // ie, a temporary without allocation
99 inline bool empty() const;
101 //- Is this temporary object valid,
102 // ie, it is a reference or a temporary that has been allocated
103 inline bool valid() const;
107 //- Return tmp pointer for reuse
108 inline T* ptr() const;
110 //- If object pointer points to valid object:
111 // delete object and set pointer to NULL
112 inline void clear() const;
117 //- Dereference operator
118 inline T& operator()();
120 //- Const dereference operator
121 inline const T& operator()() const;
123 //- Const cast to the underlying type reference
124 inline operator const T&() const;
126 //- Return object pointer
127 inline T* operator->();
129 //- Return const object pointer
130 inline const T* operator->() const;
132 //- Assignment operator
133 inline void operator=(const tmp<T>&);
137 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
139 } // End namespace Foam
141 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 // ************************************************************************* //