1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 // * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
29 inline const Foam::Xfer<T>& Foam::Xfer<T>::null()
31 return *reinterpret_cast< Xfer<T>* >(0);
35 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 inline Foam::Xfer<T>::Xfer(T* p)
45 inline Foam::Xfer<T>::Xfer(T& t, bool allowTransfer)
61 inline Foam::Xfer<T>::Xfer(const T& t)
70 inline Foam::Xfer<T>::Xfer(const Xfer<T>& t)
74 ptr_->transfer(*(t.ptr_));
78 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
81 inline Foam::Xfer<T>::~Xfer()
88 // * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * * //
91 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
94 inline void Foam::Xfer<T>::operator=(T& t)
101 inline void Foam::Xfer<T>::operator=(const Xfer<T>& t)
103 // silently ignore attempted copy to self
106 ptr_->transfer(*(t.ptr_));
112 inline T& Foam::Xfer<T>::operator()() const
119 inline T* Foam::Xfer<T>::operator->() const
125 // * * * * * * * * * * * * * Helper Functions * * * * * * * * * * * * * * * //
129 inline Foam::Xfer<T> Foam::xferCopy(const T& t)
131 return Foam::Xfer<T>(t);
136 inline Foam::Xfer<T> Foam::xferMove(T& t)
138 return Foam::Xfer<T>(t, true);
143 inline Foam::Xfer<T> Foam::xferTmp(Foam::tmp<T>& tt)
145 return Foam::Xfer<T>(tt(), tt.isTmp());
149 template<class To, class From>
150 inline Foam::Xfer<To> Foam::xferCopyTo(const From& t)
158 template<class To, class From>
159 inline Foam::Xfer<To> Foam::xferMoveTo(From& t)
167 // ************************************************************************* //