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