35 return type_ == REUSABLE_TMP || type_ == NON_RESUSABLE_TMP;
46 if (ptr_->count() > 1)
49 <<
"Attempt to create more than 2 tmp's referring to"
50 " the same object of type " << typeName()
61 type_(nonReusable ? NON_RESUSABLE_TMP : REUSABLE_TMP),
64 if (tPtr && !tPtr->unique())
67 <<
"Attempted construction of a " <<
typeName()
68 <<
" from non-unique pointer"
78 ptr_(const_cast<
T*>(&tRef))
97 <<
"Attempted copy of a deallocated " <<
typeName()
140 if (allowTransfer && type_ == REUSABLE_TMP)
152 <<
"Attempted copy of a deallocated " << typeName()
171 return type_ == REUSABLE_TMP;
178 return (isAnyTmp() && !ptr_);
185 return (!isAnyTmp() || (isAnyTmp() && ptr_));
192 return "tmp<" +
word(
typeid(
T).
name()) +
'>';
204 << typeName() <<
" deallocated"
211 <<
"Attempt to acquire non-const reference to const object"
212 <<
" from a " << typeName()
228 << typeName() <<
" deallocated"
235 <<
"Attempt to acquire pointer to object referred to"
236 <<
" by multiple temporaries of type " << typeName()
247 return ptr_->clone().ptr();
255 if (isAnyTmp() && ptr_)
282 << typeName() <<
" deallocated"
302 << typeName() <<
" deallocated"
327 << typeName() <<
" deallocated"
334 <<
"Attempt to cast const object to non-const for a " << typeName()
345 if (isAnyTmp() && !ptr_)
348 << typeName() <<
" deallocated"
364 <<
"Attempted copy of a deallocated " << typeName()
368 if (tPtr && !tPtr->unique())
371 <<
"Attempted assignment of a " << typeName()
372 <<
" to non-unique pointer"
376 type_ = REUSABLE_TMP;
391 <<
"Attempted assignment to a deallocated " << typeName()
403 <<
"Attempted assignment to a const reference to an object"
404 <<
" of type " <<
typeid(
T).
name()
A class for managing temporary objects.
void operator=(T *)
Assignment to pointer changing this tmp to a temporary T.
bool valid() const
Is this temporary object valid,.
T * operator->()
Return object pointer.
word typeName() const
Return the type name of the tmp.
bool empty() const
Return true if this temporary object empty,.
bool isTmp() const
Return true if this is really a temporary object.
tmp(T *=0, bool nonReusable=false)
Store object pointer of a non-reusable or reusable temporary object.
~tmp()
Destructor. Deletes temporary object when the reference count is 0.
T * ptr() const
Return tmp pointer for reuse.
void clear() const
If object pointer points to valid object:
T & ref() const
Return non-const reference or generate a fatal error.
const T & operator()() const
Const dereference operator.
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
errorManip< error > abort(error &err)
void T(LagrangianPatchField< Type > &f, const LagrangianPatchField< Type > &f1)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.