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
     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 
    21 /**
    22  @file
    23  @publishedPartner
    24  @released    
    25 */
    26 
    27 
    28 #ifndef __MCTTOKENOBJECT_H__
    29 #define __MCTTOKENOBJECT_H__
    30 
    31 class MCTToken;
    32 
    33 /** 
    34  * The base class for all token objects.
    35  *
    36  * Any object representing something managed via a particular token interface 
    37  * should be derived from this class. It provides certain common attributes that 
    38  * all objects must have (e.g. Label, Type, Token, Handle) and code to interact 
    39  * with the token's reference counting code. Token objects themselves are not 
    40  * reference counted, but the token will not be closed while token objects from 
    41  * it remain in existence. (Token objects can implement their own reference counting 
    42  * framework if required.) 
    43  *
    44  * @since v7.0 
    45  */
    46 class MCTTokenObject 
    47 	{
    48 public:
    49 	/** 
    50 	 * Releases the MCTTokenObject object.
    51 	 *
    52 	 * To be called when you have finished with the object. 
    53 	 */
    54 	IMPORT_C void Release();
    55 
    56 	/** 
    57 	 * Gets the object's human-readable label.	
    58 	 *
    59 	 * @return	A human-readable label of the object. 
    60 	 */
    61 	virtual const TDesC& Label() const = 0;
    62 	
    63 	/** 
    64 	 * Gets a reference to the associated token.
    65 	 *
    66 	 * @return	The associated token. 
    67 	 */
    68 	virtual MCTToken& Token() const = 0;
    69 
    70 	/** 
    71 	 * Gets the UID representing the type of the token object.
    72 	 *
    73 	 * The meanings of possible UIDs should be documented in the documentation for 
    74 	 * the interface that returns them.
    75 	 *
    76 	 * @return	The UID representing the type of the token object. 
    77 	 */
    78 	virtual TUid Type() const = 0;
    79 
    80 	/** 
    81 	 * Gets a handle for the object.
    82 	 *
    83 	 * The primary purpose of the handle is to allow token objects to be 'passed' 
    84 	 * between processes. 
    85 	 *
    86 	 * @see TCTTokenObjectHandle for more details. 
    87 	 * @return	The handle of the Token Object. 
    88 	 */
    89 	virtual TCTTokenObjectHandle Handle() const = 0;
    90  protected:
    91 	/** 
    92 	 * Releases the object once the base-class framework work has been done.
    93 	 * 
    94 	 * The default implementation simply does a 'delete this', but derived classes 
    95 	 * can substitute their own behaviour; for instance, to implement reference counting 
    96 	 * of the token objects themselves. 
    97 	 */
    98 	IMPORT_C virtual void DoRelease();
    99 
   100 	/**
   101 	 * Constructor. This needs a token in order to increment the
   102 	 * token's reference count. 
   103 	 * 
   104 	 * @param aToken	The associated token.
   105 	 */
   106 	IMPORT_C MCTTokenObject(MCTToken& aToken);
   107 
   108 	/** This destructor is protected as clients should use Release() instead. 
   109 	*/
   110 	inline virtual ~MCTTokenObject() = 0;
   111 
   112 	/** 
   113 	 * Increments the token's reference count by one.  
   114 	 * 
   115 	 * This is neccessary to allow derived classes to implement their own 
   116 	 * reference counting, as Release() automatically call Release() on the token. 
   117 	 */
   118 	IMPORT_C void AddTokenRef();
   119 	};
   120 
   121 /** 
   122  * Destructor.
   123  *
   124  * Frees all resources owned by the object, prior to its destruction. 
   125  */
   126 inline MCTTokenObject::~MCTTokenObject()
   127 	{
   128 	}
   129 
   130 #endif