Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
2a3bb0f5
Commit
2a3bb0f5
authored
Oct 24, 2008
by
Mark Olesen
Browse files
autoPtr, tmp cosmetics
- dropped non-const tmp::clear() in favour of the const version
parent
7d081f0e
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/OpenFOAM/memory/autoPtr/autoPtr.H
View file @
2a3bb0f5
...
...
@@ -62,7 +62,7 @@ public:
// Constructors
//- Store object pointer
inline
explicit
autoPtr
(
T
*
=
NULL
);
inline
explicit
autoPtr
(
T
*
=
0
);
//- Construct as copy by transfering pointer to this autoPtr and
// setting the arguments pointer to NULL
...
...
@@ -90,11 +90,11 @@ public:
//- Set pointer to that given.
// If object pointer already set issue a FatalError.
inline
void
set
(
T
*
p
);
inline
void
set
(
T
*
);
//- If object pointer already set delete object and
// set pointer to that given
inline
void
reset
(
T
*
p
=
NULL
);
inline
void
reset
(
T
*
=
0
);
//- If object pointer points to valid object:
// delete object and set pointer to NULL
...
...
src/OpenFOAM/memory/autoPtr/autoPtrI.H
View file @
2a3bb0f5
...
...
@@ -29,9 +29,9 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template
<
class
T
>
inline
Foam
::
autoPtr
<
T
>::
autoPtr
(
T
*
tPtr
)
inline
Foam
::
autoPtr
<
T
>::
autoPtr
(
T
*
p
)
:
ptr_
(
tPtr
)
ptr_
(
p
)
{}
...
...
@@ -40,7 +40,7 @@ inline Foam::autoPtr<T>::autoPtr(const autoPtr<T>& ap)
:
ptr_
(
ap
.
ptr_
)
{
ap
.
ptr_
=
NULL
;
ap
.
ptr_
=
0
;
}
...
...
@@ -64,7 +64,7 @@ template<class T>
inline
T
*
Foam
::
autoPtr
<
T
>::
ptr
()
{
T
*
ptr
=
ptr_
;
ptr_
=
NULL
;
ptr_
=
0
;
return
ptr
;
}
...
...
@@ -74,7 +74,7 @@ inline void Foam::autoPtr<T>::set(T* p)
{
if
(
ptr_
)
{
FatalErrorIn
(
"void autoPtr<T>::set(T*
p
)"
)
FatalErrorIn
(
"void autoPtr<T>::set(T*)"
)
<<
"object already allocated"
<<
abort
(
FatalError
);
}
...
...
@@ -98,7 +98,7 @@ inline void Foam::autoPtr<T>::reset(T* p)
template
<
class
T
>
inline
void
Foam
::
autoPtr
<
T
>::
clear
()
{
reset
(
NULL
);
reset
(
0
);
}
...
...
src/OpenFOAM/memory/tmp/tmp.H
View file @
2a3bb0f5
...
...
@@ -98,16 +98,11 @@ public:
// or a temporary that has been allocated
inline
bool
valid
()
const
;
// Edit
//- Return tmp pointer for reuse
inline
T
*
ptr
()
const
;
//- If object pointer points to valid object:
// delete object and set pointer to NULL
inline
void
clear
();
//- If object pointer points to valid object:
// delete object and set pointer to NULL
inline
void
clear
()
const
;
...
...
src/OpenFOAM/memory/tmp/tmpI.H
View file @
2a3bb0f5
...
...
@@ -26,15 +26,10 @@ License
#include
"error.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace
Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template
<
class
T
>
inline
tmp
<
T
>::
tmp
(
T
*
tPtr
)
inline
Foam
::
tmp
<
T
>::
tmp
(
T
*
tPtr
)
:
isTmp_
(
true
),
ptr_
(
tPtr
),
...
...
@@ -43,16 +38,16 @@ inline tmp<T>::tmp(T* tPtr)
template
<
class
T
>
inline
tmp
<
T
>::
tmp
(
const
T
&
tRef
)
inline
Foam
::
tmp
<
T
>::
tmp
(
const
T
&
tRef
)
:
isTmp_
(
false
),
ptr_
(
NULL
),
ptr_
(
0
),
ref_
(
tRef
)
{}
template
<
class
T
>
inline
tmp
<
T
>::
tmp
(
const
tmp
<
T
>&
t
)
inline
Foam
::
tmp
<
T
>::
tmp
(
const
tmp
<
T
>&
t
)
:
isTmp_
(
t
.
isTmp_
),
ptr_
(
t
.
ptr_
),
...
...
@@ -75,14 +70,14 @@ inline tmp<T>::tmp(const tmp<T>& t)
template
<
class
T
>
inline
tmp
<
T
>::~
tmp
()
inline
Foam
::
tmp
<
T
>::~
tmp
()
{
if
(
isTmp_
&&
ptr_
)
{
if
(
ptr_
->
okToDelete
())
{
delete
ptr_
;
ptr_
=
NULL
;
ptr_
=
0
;
}
else
{
...
...
@@ -95,21 +90,21 @@ inline tmp<T>::~tmp()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template
<
class
T
>
inline
bool
tmp
<
T
>::
isTmp
()
const
inline
bool
Foam
::
tmp
<
T
>::
isTmp
()
const
{
return
isTmp_
;
}
template
<
class
T
>
inline
bool
tmp
<
T
>::
valid
()
const
inline
bool
Foam
::
tmp
<
T
>::
valid
()
const
{
return
(
!
isTmp_
||
(
isTmp_
&&
ptr_
));
}
template
<
class
T
>
inline
T
*
tmp
<
T
>::
ptr
()
const
inline
T
*
Foam
::
tmp
<
T
>::
ptr
()
const
{
if
(
isTmp_
)
{
...
...
@@ -121,7 +116,7 @@ inline T* tmp<T>::ptr() const
}
T
*
ptr
=
ptr_
;
ptr_
=
NULL
;
ptr_
=
0
;
ptr
->
resetRefCount
();
...
...
@@ -135,27 +130,20 @@ inline T* tmp<T>::ptr() const
template
<
class
T
>
inline
void
tmp
<
T
>::
clear
()
inline
void
Foam
::
tmp
<
T
>::
clear
()
const
{
if
(
isTmp_
&&
ptr_
)
// && ptr_->okToDelete())
{
delete
ptr_
;
ptr_
=
NULL
;
ptr_
=
0
;
}
}
template
<
class
T
>
inline
void
tmp
<
T
>::
clear
()
const
{
const_cast
<
tmp
<
T
>&>
(
*
this
).
clear
();
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template
<
class
T
>
inline
T
&
tmp
<
T
>::
operator
()()
inline
T
&
Foam
::
tmp
<
T
>::
operator
()()
{
if
(
isTmp_
)
{
...
...
@@ -181,7 +169,7 @@ inline T& tmp<T>::operator()()
template
<
class
T
>
inline
const
T
&
tmp
<
T
>::
operator
()()
const
inline
const
T
&
Foam
::
tmp
<
T
>::
operator
()()
const
{
if
(
isTmp_
)
{
...
...
@@ -202,14 +190,14 @@ inline const T& tmp<T>::operator()() const
template
<
class
T
>
inline
tmp
<
T
>::
operator
const
T
&
()
const
inline
Foam
::
tmp
<
T
>::
operator
const
T
&
()
const
{
return
operator
()();
}
template
<
class
T
>
inline
T
*
tmp
<
T
>::
operator
->
()
inline
T
*
Foam
::
tmp
<
T
>::
operator
->
()
{
if
(
isTmp_
)
{
...
...
@@ -230,21 +218,21 @@ inline T* tmp<T>::operator->()
template
<
class
T
>
inline
const
T
*
tmp
<
T
>::
operator
->
()
const
inline
const
T
*
Foam
::
tmp
<
T
>::
operator
->
()
const
{
return
const_cast
<
tmp
<
T
>&>
(
*
this
).
operator
->
();
}
template
<
class
T
>
inline
void
tmp
<
T
>::
operator
=
(
const
tmp
<
T
>&
t
)
inline
void
Foam
::
tmp
<
T
>::
operator
=
(
const
tmp
<
T
>&
t
)
{
if
(
isTmp_
&&
ptr_
)
{
if
(
ptr_
->
okToDelete
())
{
delete
ptr_
;
ptr_
=
NULL
;
ptr_
=
0
;
}
else
{
...
...
@@ -277,8 +265,4 @@ inline void tmp<T>::operator=(const tmp<T>& t)
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
}
// End namespace Foam
// ************************************************************************* //
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment