Pointer< Type > Class Template Reference
A Smartpointer with reference counter.
More...
#include <tools.h>
List of all members.
Public Member Functions |
| Pointer () |
| Constructor for NULL-Pointer.
|
| Pointer (Type *obj_, bool del_=true) |
| Constructor for an Type*.
|
| Pointer (const Pointer< Type > &p) |
| Copy-Constructor for a Pointer<Type>.
|
| ~Pointer () |
| Destructor.
|
Pointer< Type > & | operator= (const Pointer< Type > &p) |
| Assign-Operator for another Pointer.
|
Pointer< Type > & | operator= (Type *obj_) |
| Assign-Operator for a normal pointer.
|
| operator Type * () const |
| Cast-operator to give the pointer to the object, this Pointer points to.
|
Type & | operator* () const |
| Cast-operator to give the pointer to the object, this Pointer points to as const.
|
Type * | operator-> () const |
| Dereference-operator ->.
|
bool | operator!= (const Type *obj_) const |
| Compare operator.
|
int | count () const |
| Gives the number of Pointers, pointing to *obj.
|
Static Public Member Functions |
static int | count (const Type *obj_) |
| Gives the number of Pointer's to an object.
|
Private Member Functions |
void | inc_count () |
| Increase the counter for this object of adds it to the map.
|
int | dec_count () |
| Decrease the counter for obj.
|
Private Attributes |
Type * | obj |
| The object, this pointer points to.
|
bool | delete_obj |
| Indicates, whether the object should be deleted, when the last Pointer to it will be deleted.
|
Detailed Description
template<class Type>
class Pointer< Type >
A Smartpointer with reference counter.
When the last Pointer to an object is killed, the object itselfe will be killed.
Definition at line 59 of file tools.h.
Constructor & Destructor Documentation
Constructor for NULL-Pointer.
Definition at line 108 of file tools.h.
Constructor for an Type*.
- Parameters:
-
| obj_ | The pointer to the object, this pointer shoud point to. |
| del_ | Indicates, whether to object should be deleted, when the last Pointer to it will be deleted. Default is true. |
Definition at line 116 of file tools.h.
Copy-Constructor for a Pointer<Type>.
- Parameters:
-
Definition at line 124 of file tools.h.
Destructor.
If this was the last Pointer to the object, the object is not NULL and delete_obj is true, the object will be deleted.
Definition at line 132 of file tools.h.
Member Function Documentation
template<class Type>
static int Pointer< Type >::count |
( |
const Type * |
obj_ |
) |
[inline, static] |
Gives the number of Pointer's to an object.
- Parameters:
-
| obj_ | The pointer to the object. |
- Returns:
- The number of Pointer's to *obj_.
- See also:
- count(const void&)
Definition at line 66 of file tools.h.
template<class Type>
void Pointer< Type >::inc_count |
( |
|
) |
[inline, private] |
Increase the counter for this object of adds it to the map.
If obj doesn't exist in the map, it will be added. Else the counter for obj will be increased.
Definition at line 81 of file tools.h.
template<class Type>
int Pointer< Type >::dec_count |
( |
|
) |
[inline, private] |
Decrease the counter for obj.
- Returns:
- The new counter.
Definition at line 89 of file tools.h.
Assign-Operator for another Pointer.
- Parameters:
-
Definition at line 139 of file tools.h.
Assign-Operator for a normal pointer.
Sets delete_obj to true, if it's no self-assignment.
- Parameters:
-
| obj_ | The pointer to copy. |
Definition at line 151 of file tools.h.
template<class Type>
Pointer< Type >::operator Type * |
( |
|
) |
const [inline] |
Cast-operator to give the pointer to the object, this Pointer points to.
- Returns:
- obj.
Definition at line 162 of file tools.h.
template<class Type>
Type& Pointer< Type >::operator* |
( |
|
) |
const [inline] |
Cast-operator to give the pointer to the object, this Pointer points to as const.
- Returns:
- obj. Cast-operator to bool.
-
True, if this is not a NULL-Pointer. False, else. Dereference-operator *.
-
A reference to *obj (&*obj), if obj is not NULL.
Definition at line 177 of file tools.h.
template<class Type>
Type* Pointer< Type >::operator-> |
( |
|
) |
const [inline] |
Dereference-operator ->.
- Returns:
- A reference to *obj (&*obj), if obj is not NULL.
Definition at line 187 of file tools.h.
template<class Type>
bool Pointer< Type >::operator!= |
( |
const Type * |
obj_ |
) |
const [inline] |
Compare operator.
- Parameters:
-
| obj_ | The pointer to compare with. |
- Returns:
- True, if obj_ points to the same object, obj does. False, else. Compare operator.
- Parameters:
-
| obj_ | The pointer to compare with. |
- Returns:
- True, if obj_ doesn't point to the same object, obj does. False, else.
Definition at line 206 of file tools.h.
template<class Type>
int Pointer< Type >::count |
( |
|
) |
const [inline] |
Gives the number of Pointers, pointing to *obj.
- Returns:
- The number of Pointers, pointing to *obj.
Definition at line 213 of file tools.h.
Member Data Documentation
The object, this pointer points to.
Definition at line 75 of file tools.h.
Indicates, whether the object should be deleted, when the last Pointer to it will be deleted.
The default value is true.
Definition at line 102 of file tools.h.
The documentation for this class was generated from the following file: