Symbian3/SDK/Source/GUID-48C764A2-378F-57CC-B7F2-EC866AE8F830.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 11 Jun 2010 15:24:34 +0100
changeset 9 59758314f811
parent 8 ae94777fff8f
child 13 48780e181b38
permissions -rw-r--r--
Week 23 contribution of PDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept xml:lang="en" id="GUID-48C764A2-378F-57CC-B7F2-EC866AE8F830"><title>The reference counting object</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>A reference counting object is one which uses reference counting to track concurrent references to itself and which arranges for automatic destruction of itself when the final reference is removed. It is also an object which can be named. </p> <p>A reference counting object is any object which has <codeph>CObject</codeph> as its base class. </p> <p>Constructing a <xref href="GUID-9230EF62-376A-389C-B720-7C1EDCB7EA97.dita"><apiname>CObject</apiname></xref> derived type, or calling its <xref href="GUID-9230EF62-376A-389C-B720-7C1EDCB7EA97.dita#GUID-9230EF62-376A-389C-B720-7C1EDCB7EA97/GUID-E6319811-605D-3329-9314-ED25F4A9116C"><apiname>CObject::Open()</apiname></xref> member function, adds a reference to that object by adding one to its reference count. Calling its <xref href="GUID-9230EF62-376A-389C-B720-7C1EDCB7EA97.dita#GUID-9230EF62-376A-389C-B720-7C1EDCB7EA97/GUID-6E50F446-307B-3C9D-9AD6-AFCB49B2F658"><apiname>CObject::Close()</apiname></xref> member function removes a reference by subtracting one from its reference count. When the last user of the object calls <xref href="GUID-9230EF62-376A-389C-B720-7C1EDCB7EA97.dita#GUID-9230EF62-376A-389C-B720-7C1EDCB7EA97/GUID-6E50F446-307B-3C9D-9AD6-AFCB49B2F658"><apiname>CObject::Close()</apiname></xref>, the reference count becomes zero and the object is automatically destroyed. </p> <p>The following drawing shows the idea. </p> <fig id="GUID-18A04428-FBD7-5115-B206-6F2E67343A7F"><image href="GUID-39AAB0D3-6D4D-5DE3-B894-F5E763D3E19B_d0e244607_href.png" placement="inline"/></fig> <p>A <xref href="GUID-9230EF62-376A-389C-B720-7C1EDCB7EA97.dita"><apiname>CObject</apiname></xref> is always part of a class hierarchy. It is a base class; an explicit <xref href="GUID-9230EF62-376A-389C-B720-7C1EDCB7EA97.dita"><apiname>CObject</apiname></xref> type is never instantiated. </p> <p>The server side implementation of a client/server subsession uses a <xref href="GUID-9230EF62-376A-389C-B720-7C1EDCB7EA97.dita"><apiname>CObject</apiname></xref>. </p> <p>See also: </p> <ul><li id="GUID-20A9F23B-19B5-5D70-9943-811FC42F3BED"><p> <xref href="GUID-9230EF62-376A-389C-B720-7C1EDCB7EA97.dita"><apiname>CObject</apiname></xref>  </p> </li> <li id="GUID-8C980E14-F073-5918-AD66-8547656BC13D"><p> <xref href="GUID-1CC6FEF0-7D1E-5329-8276-22ACFE3DE362.dita">Subsessions within a session</xref>  </p> </li> <li id="GUID-C5FCE438-1F8B-569C-9257-0EBE9D823747"><p> <xref href="GUID-6047DB3F-DC92-51DF-9EEB-00E79E890B54.dita">Using client/server</xref>  </p> </li> </ul> </conbody></concept>