oasys::TempRef< _Type > Class Template Reference

#include <TempRef.h>

List of all members.


Detailed Description

template<typename _Type>
class oasys::TempRef< _Type >

For functions that want to return an ObjectRef, it's irritating to have to go through a series of add_ref and del_ref calls to deal with the C++ temporary objects that are created.

Therefore, this class holds a pointer to a reference counted object but doesn't up the reference count, and enforces that the pointer is released before the class is destroyed since the temporary destructor will PANIC if the pointer is non-NULL;

Definition at line 37 of file TempRef.h.


Public Member Functions

 TempRef (const char *what1, const char *what2="")
 Constructor that initializes the pointer to be empty.
 TempRef (_Type *object, const char *what1, const char *what2="")
 Constructor that takes an initial pointer for assignment.
 TempRef (const TempRef &other)
 Copy constructor.
 ~TempRef ()
 Destructor that asserts the pointer was claimed.
TempRefoperator= (const TempRef< _Type > &other)
 Assignment operator.
TempRefoperator= (_Type *object)
 Assignment operator.
_Type * object () const
 Accessor for the object.
_Type * operator-> () const
 Operator overload for pointer access.
_Type & operator * () const
 Operator overload for pointer access.
void release () const
 Release the reference to the object.
bool operator== (_Type *o)
 Equality operator.
bool operator!= (_Type *o)
 Inequality operator.
const char * what1 () const
const char * what2 () const

Private Attributes

_Type * object_
 The object pointer.
const char * what1_
 Debugging strings.
const char * what2_

Constructor & Destructor Documentation

template<typename _Type>
oasys::TempRef< _Type >::TempRef ( const char *  what1,
const char *  what2 = "" 
) [inline]

Constructor that initializes the pointer to be empty.

Definition at line 42 of file TempRef.h.

template<typename _Type>
oasys::TempRef< _Type >::TempRef ( _Type *  object,
const char *  what1,
const char *  what2 = "" 
) [inline]

Constructor that takes an initial pointer for assignment.

Definition at line 50 of file TempRef.h.

template<typename _Type>
oasys::TempRef< _Type >::TempRef ( const TempRef< _Type > &  other  )  [inline]

Copy constructor.

Definition at line 58 of file TempRef.h.

References oasys::TempRef< _Type >::object(), oasys::TempRef< _Type >::object_, and oasys::TempRef< _Type >::release().

template<typename _Type>
oasys::TempRef< _Type >::~TempRef (  )  [inline]

Destructor that asserts the pointer was claimed.

Definition at line 67 of file TempRef.h.

References oasys::TempRef< _Type >::object_, oasys::TempRef< _Type >::what1_, and oasys::TempRef< _Type >::what2_.


Member Function Documentation

template<typename _Type>
TempRef& oasys::TempRef< _Type >::operator= ( const TempRef< _Type > &  other  )  [inline]

Assignment operator.

Definition at line 77 of file TempRef.h.

References oasys::TempRef< _Type >::object(), oasys::TempRef< _Type >::object_, and oasys::TempRef< _Type >::release().

template<typename _Type>
TempRef& oasys::TempRef< _Type >::operator= ( _Type *  object  )  [inline]

Assignment operator.

Definition at line 87 of file TempRef.h.

References oasys::TempRef< _Type >::object_.

template<typename _Type>
_Type* oasys::TempRef< _Type >::object (  )  const [inline]

Accessor for the object.

Definition at line 98 of file TempRef.h.

References oasys::TempRef< _Type >::object_.

Referenced by oasys::TempRef< _Type >::operator=(), oasys::Ref< _Type >::operator=(), oasys::Ref< _Type >::Ref(), and oasys::TempRef< _Type >::TempRef().

template<typename _Type>
_Type* oasys::TempRef< _Type >::operator-> (  )  const [inline]

Operator overload for pointer access.

Definition at line 105 of file TempRef.h.

References oasys::TempRef< _Type >::object_.

template<typename _Type>
_Type& oasys::TempRef< _Type >::operator * (  )  const [inline]

Operator overload for pointer access.

Definition at line 113 of file TempRef.h.

References oasys::TempRef< _Type >::object_.

template<typename _Type>
void oasys::TempRef< _Type >::release (  )  const [inline]

Release the reference to the object.

Note this is declared const even though it technically modifies the object.

Definition at line 122 of file TempRef.h.

References oasys::TempRef< _Type >::object_.

Referenced by oasys::TempRef< _Type >::operator=(), oasys::Ref< _Type >::operator=(), oasys::Ref< _Type >::Ref(), and oasys::TempRef< _Type >::TempRef().

template<typename _Type>
bool oasys::TempRef< _Type >::operator== ( _Type *  o  )  [inline]

Equality operator.

Definition at line 129 of file TempRef.h.

References oasys::TempRef< _Type >::object_.

template<typename _Type>
bool oasys::TempRef< _Type >::operator!= ( _Type *  o  )  [inline]

Inequality operator.

Definition at line 137 of file TempRef.h.

References oasys::TempRef< _Type >::object_.

template<typename _Type>
const char* oasys::TempRef< _Type >::what1 (  )  const [inline]

Definition at line 142 of file TempRef.h.

References oasys::TempRef< _Type >::what1_.

template<typename _Type>
const char* oasys::TempRef< _Type >::what2 (  )  const [inline]

Definition at line 143 of file TempRef.h.

References oasys::TempRef< _Type >::what2_.


Member Data Documentation

template<typename _Type>
_Type* oasys::TempRef< _Type >::object_ [mutable, private]

The object pointer.

Definition at line 149 of file TempRef.h.

Referenced by oasys::TempRef< _Type >::object(), oasys::TempRef< _Type >::operator *(), oasys::TempRef< _Type >::operator!=(), oasys::TempRef< _Type >::operator->(), oasys::TempRef< _Type >::operator=(), oasys::TempRef< _Type >::operator==(), oasys::TempRef< _Type >::release(), oasys::TempRef< _Type >::TempRef(), and oasys::TempRef< _Type >::~TempRef().

template<typename _Type>
const char* oasys::TempRef< _Type >::what1_ [private]

Debugging strings.

Definition at line 154 of file TempRef.h.

Referenced by oasys::TempRef< _Type >::what1(), and oasys::TempRef< _Type >::~TempRef().

template<typename _Type>
const char * oasys::TempRef< _Type >::what2_ [private]

Definition at line 154 of file TempRef.h.

Referenced by oasys::TempRef< _Type >::what2(), and oasys::TempRef< _Type >::~TempRef().


The documentation for this class was generated from the following file:
Generated on Sat Sep 8 08:36:26 2007 for DTN Reference Implementation by  doxygen 1.5.3