epoc32/include/ct/mcttokenobject.h
branchSymbian2
changeset 2 2fe1408b6811
child 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/ct/mcttokenobject.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,130 @@
     1.4 +/*
     1.5 +* Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of the License "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +
    1.23 +
    1.24 +/**
    1.25 + @file
    1.26 + @publishedPartner
    1.27 + @released    
    1.28 +*/
    1.29 +
    1.30 +
    1.31 +#ifndef __MCTTOKENOBJECT_H__
    1.32 +#define __MCTTOKENOBJECT_H__
    1.33 +
    1.34 +class MCTToken;
    1.35 +
    1.36 +/** 
    1.37 + * The base class for all token objects.
    1.38 + *
    1.39 + * Any object representing something managed via a particular token interface 
    1.40 + * should be derived from this class. It provides certain common attributes that 
    1.41 + * all objects must have (e.g. Label, Type, Token, Handle) and code to interact 
    1.42 + * with the token's reference counting code. Token objects themselves are not 
    1.43 + * reference counted, but the token will not be closed while token objects from 
    1.44 + * it remain in existence. (Token objects can implement their own reference counting 
    1.45 + * framework if required.) 
    1.46 + *
    1.47 + * @since v7.0 
    1.48 + */
    1.49 +class MCTTokenObject 
    1.50 +	{
    1.51 +public:
    1.52 +	/** 
    1.53 +	 * Releases the MCTTokenObject object.
    1.54 +	 *
    1.55 +	 * To be called when you have finished with the object. 
    1.56 +	 */
    1.57 +	IMPORT_C void Release();
    1.58 +
    1.59 +	/** 
    1.60 +	 * Gets the object's human-readable label.	
    1.61 +	 *
    1.62 +	 * @return	A human-readable label of the object. 
    1.63 +	 */
    1.64 +	virtual const TDesC& Label() const = 0;
    1.65 +	
    1.66 +	/** 
    1.67 +	 * Gets a reference to the associated token.
    1.68 +	 *
    1.69 +	 * @return	The associated token. 
    1.70 +	 */
    1.71 +	virtual MCTToken& Token() const = 0;
    1.72 +
    1.73 +	/** 
    1.74 +	 * Gets the UID representing the type of the token object.
    1.75 +	 *
    1.76 +	 * The meanings of possible UIDs should be documented in the documentation for 
    1.77 +	 * the interface that returns them.
    1.78 +	 *
    1.79 +	 * @return	The UID representing the type of the token object. 
    1.80 +	 */
    1.81 +	virtual TUid Type() const = 0;
    1.82 +
    1.83 +	/** 
    1.84 +	 * Gets a handle for the object.
    1.85 +	 *
    1.86 +	 * The primary purpose of the handle is to allow token objects to be 'passed' 
    1.87 +	 * between processes. 
    1.88 +	 *
    1.89 +	 * @see TCTTokenObjectHandle for more details. 
    1.90 +	 * @return	The handle of the Token Object. 
    1.91 +	 */
    1.92 +	virtual TCTTokenObjectHandle Handle() const = 0;
    1.93 + protected:
    1.94 +	/** 
    1.95 +	 * Releases the object once the base-class framework work has been done.
    1.96 +	 * 
    1.97 +	 * The default implementation simply does a 'delete this', but derived classes 
    1.98 +	 * can substitute their own behaviour; for instance, to implement reference counting 
    1.99 +	 * of the token objects themselves. 
   1.100 +	 */
   1.101 +	IMPORT_C virtual void DoRelease();
   1.102 +
   1.103 +	/**
   1.104 +	 * Constructor. This needs a token in order to increment the
   1.105 +	 * token's reference count. 
   1.106 +	 * 
   1.107 +	 * @param aToken	The associated token.
   1.108 +	 */
   1.109 +	IMPORT_C MCTTokenObject(MCTToken& aToken);
   1.110 +
   1.111 +	/** This destructor is protected as clients should use Release() instead. 
   1.112 +	*/
   1.113 +	inline virtual ~MCTTokenObject() = 0;
   1.114 +
   1.115 +	/** 
   1.116 +	 * Increments the token's reference count by one.  
   1.117 +	 * 
   1.118 +	 * This is neccessary to allow derived classes to implement their own 
   1.119 +	 * reference counting, as Release() automatically call Release() on the token. 
   1.120 +	 */
   1.121 +	IMPORT_C void AddTokenRef();
   1.122 +	};
   1.123 +
   1.124 +/** 
   1.125 + * Destructor.
   1.126 + *
   1.127 + * Frees all resources owned by the object, prior to its destruction. 
   1.128 + */
   1.129 +inline MCTTokenObject::~MCTTokenObject()
   1.130 +	{
   1.131 +	}
   1.132 +
   1.133 +#endif