epoc32/include/ct/mcttokenobject.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
child 4 837f303aceeb
permissions -rw-r--r--
Final list of Symbian^2 public API header files
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     3
* All rights reserved.
williamr@2
     4
* This component and the accompanying materials are made available
williamr@2
     5
* under the terms of the License "Eclipse Public License v1.0"
williamr@2
     6
* which accompanies this distribution, and is available
williamr@2
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@2
     8
*
williamr@2
     9
* Initial Contributors:
williamr@2
    10
* Nokia Corporation - initial contribution.
williamr@2
    11
*
williamr@2
    12
* Contributors:
williamr@2
    13
*
williamr@2
    14
* Description: 
williamr@2
    15
*
williamr@2
    16
*/
williamr@2
    17
williamr@2
    18
williamr@2
    19
williamr@2
    20
williamr@2
    21
/**
williamr@2
    22
 @file
williamr@2
    23
 @publishedPartner
williamr@2
    24
 @released    
williamr@2
    25
*/
williamr@2
    26
williamr@2
    27
williamr@2
    28
#ifndef __MCTTOKENOBJECT_H__
williamr@2
    29
#define __MCTTOKENOBJECT_H__
williamr@2
    30
williamr@2
    31
class MCTToken;
williamr@2
    32
williamr@2
    33
/** 
williamr@2
    34
 * The base class for all token objects.
williamr@2
    35
 *
williamr@2
    36
 * Any object representing something managed via a particular token interface 
williamr@2
    37
 * should be derived from this class. It provides certain common attributes that 
williamr@2
    38
 * all objects must have (e.g. Label, Type, Token, Handle) and code to interact 
williamr@2
    39
 * with the token's reference counting code. Token objects themselves are not 
williamr@2
    40
 * reference counted, but the token will not be closed while token objects from 
williamr@2
    41
 * it remain in existence. (Token objects can implement their own reference counting 
williamr@2
    42
 * framework if required.) 
williamr@2
    43
 *
williamr@2
    44
 * @since v7.0 
williamr@2
    45
 */
williamr@2
    46
class MCTTokenObject 
williamr@2
    47
	{
williamr@2
    48
public:
williamr@2
    49
	/** 
williamr@2
    50
	 * Releases the MCTTokenObject object.
williamr@2
    51
	 *
williamr@2
    52
	 * To be called when you have finished with the object. 
williamr@2
    53
	 */
williamr@2
    54
	IMPORT_C void Release();
williamr@2
    55
williamr@2
    56
	/** 
williamr@2
    57
	 * Gets the object's human-readable label.	
williamr@2
    58
	 *
williamr@2
    59
	 * @return	A human-readable label of the object. 
williamr@2
    60
	 */
williamr@2
    61
	virtual const TDesC& Label() const = 0;
williamr@2
    62
	
williamr@2
    63
	/** 
williamr@2
    64
	 * Gets a reference to the associated token.
williamr@2
    65
	 *
williamr@2
    66
	 * @return	The associated token. 
williamr@2
    67
	 */
williamr@2
    68
	virtual MCTToken& Token() const = 0;
williamr@2
    69
williamr@2
    70
	/** 
williamr@2
    71
	 * Gets the UID representing the type of the token object.
williamr@2
    72
	 *
williamr@2
    73
	 * The meanings of possible UIDs should be documented in the documentation for 
williamr@2
    74
	 * the interface that returns them.
williamr@2
    75
	 *
williamr@2
    76
	 * @return	The UID representing the type of the token object. 
williamr@2
    77
	 */
williamr@2
    78
	virtual TUid Type() const = 0;
williamr@2
    79
williamr@2
    80
	/** 
williamr@2
    81
	 * Gets a handle for the object.
williamr@2
    82
	 *
williamr@2
    83
	 * The primary purpose of the handle is to allow token objects to be 'passed' 
williamr@2
    84
	 * between processes. 
williamr@2
    85
	 *
williamr@2
    86
	 * @see TCTTokenObjectHandle for more details. 
williamr@2
    87
	 * @return	The handle of the Token Object. 
williamr@2
    88
	 */
williamr@2
    89
	virtual TCTTokenObjectHandle Handle() const = 0;
williamr@2
    90
 protected:
williamr@2
    91
	/** 
williamr@2
    92
	 * Releases the object once the base-class framework work has been done.
williamr@2
    93
	 * 
williamr@2
    94
	 * The default implementation simply does a 'delete this', but derived classes 
williamr@2
    95
	 * can substitute their own behaviour; for instance, to implement reference counting 
williamr@2
    96
	 * of the token objects themselves. 
williamr@2
    97
	 */
williamr@2
    98
	IMPORT_C virtual void DoRelease();
williamr@2
    99
williamr@2
   100
	/**
williamr@2
   101
	 * Constructor. This needs a token in order to increment the
williamr@2
   102
	 * token's reference count. 
williamr@2
   103
	 * 
williamr@2
   104
	 * @param aToken	The associated token.
williamr@2
   105
	 */
williamr@2
   106
	IMPORT_C MCTTokenObject(MCTToken& aToken);
williamr@2
   107
williamr@2
   108
	/** This destructor is protected as clients should use Release() instead. 
williamr@2
   109
	*/
williamr@2
   110
	inline virtual ~MCTTokenObject() = 0;
williamr@2
   111
williamr@2
   112
	/** 
williamr@2
   113
	 * Increments the token's reference count by one.  
williamr@2
   114
	 * 
williamr@2
   115
	 * This is neccessary to allow derived classes to implement their own 
williamr@2
   116
	 * reference counting, as Release() automatically call Release() on the token. 
williamr@2
   117
	 */
williamr@2
   118
	IMPORT_C void AddTokenRef();
williamr@2
   119
	};
williamr@2
   120
williamr@2
   121
/** 
williamr@2
   122
 * Destructor.
williamr@2
   123
 *
williamr@2
   124
 * Frees all resources owned by the object, prior to its destruction. 
williamr@2
   125
 */
williamr@2
   126
inline MCTTokenObject::~MCTTokenObject()
williamr@2
   127
	{
williamr@2
   128
	}
williamr@2
   129
williamr@2
   130
#endif