| # kdecore Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# KShared Class Reference

Reference counting for shared objects. More...

`#include <ksharedptr.h>`

Inheritance diagram for KShared:

[legend]
List of all members.

## Public Member Functions
| KShared ()
| Standard constructor.
| KShared (const KShared &)
| Copy constructor.
KShared & | operator= (const KShared &)
| Overloaded assignment operator.
void | _KShared_ref () const
| Increases the reference count by one.
void | _KShared_unref () const
| Releases a reference (decreases the reference count by one).
int | _KShared_count () const
| Return the current number of references held.

## Detailed Description

Reference counting for shared objects.

If you derive your object from this class, then you may use it in conjunction with KSharedPtr to control the lifetime of your object.

Specifically, all classes that derive from KShared have an internal counter keeping track of how many other objects have a reference to their object. If used with KSharedPtr, then your object will not be deleted until all references to the object have been released.

You should probably not ever use any of the methods in this class directly -- let the KSharedPtr take care of that. Just derive your class from KShared and forget about it.

Author:
  Waldo Bastian <bastian@kde.org>

Version:
  Id
    ksharedptr.h,v 1.20 2002/09/08 14:55:42 tjansen Exp

Definition at line 39 of file ksharedptr.h.

## Constructor & Destructor Documentation

KShared::KShared | ( |  | ) | `[inline]`

| Standard constructor. This will initialize the reference count on this object to 0. Definition at line 45 of file ksharedptr.h.

KShared::KShared | ( | const KShared & |  | ) | `[inline]`

| Copy constructor. This will not actually copy the objects but it will initialize the reference count on this object to 0. Definition at line 51 of file ksharedptr.h.

## Member Function Documentation

KShared& KShared::operator= | ( | const KShared & |  | ) | `[inline]`

| Overloaded assignment operator. Definition at line 56 of file ksharedptr.h.

void KShared::_KShared_ref | ( |  | ) | const`[inline]`

| Increases the reference count by one. Definition at line 61 of file ksharedptr.h.

void KShared::_KShared_unref | ( |  | ) | const`[inline]`

| Releases a reference (decreases the reference count by one). If the count goes to 0, this object will delete itself. Definition at line 67 of file ksharedptr.h.

int KShared::_KShared_count | ( |  | ) | const`[inline]`

| Return the current number of references held. Returns: Number of references Definition at line 74 of file ksharedptr.h.

The documentation for this class was generated from the following file:

- ksharedptr.h

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 12:51:07 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001