williamr@2: /*
williamr@2: * Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2: * All rights reserved.
williamr@2: * This component and the accompanying materials are made available
williamr@2: * under the terms of the License "Eclipse Public License v1.0"
williamr@2: * which accompanies this distribution, and is available
williamr@2: * at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@2: *
williamr@2: * Initial Contributors:
williamr@2: * Nokia Corporation - initial contribution.
williamr@2: *
williamr@2: * Contributors:
williamr@2: *
williamr@2: * Description: 
williamr@2: *
williamr@2: */
williamr@2: 
williamr@2: 
williamr@2: 
williamr@2: 
williamr@2: /**
williamr@2:  @file
williamr@2:  @publishedPartner
williamr@2:  @released    
williamr@2: */
williamr@2: 
williamr@2: 
williamr@2: #ifndef __MCTTOKENOBJECT_H__
williamr@2: #define __MCTTOKENOBJECT_H__
williamr@2: 
williamr@2: class MCTToken;
williamr@2: 
williamr@2: /** 
williamr@2:  * The base class for all token objects.
williamr@2:  *
williamr@2:  * Any object representing something managed via a particular token interface 
williamr@2:  * should be derived from this class. It provides certain common attributes that 
williamr@2:  * all objects must have (e.g. Label, Type, Token, Handle) and code to interact 
williamr@2:  * with the token's reference counting code. Token objects themselves are not 
williamr@2:  * reference counted, but the token will not be closed while token objects from 
williamr@2:  * it remain in existence. (Token objects can implement their own reference counting 
williamr@2:  * framework if required.) 
williamr@2:  *
williamr@2:  * @since v7.0 
williamr@2:  */
williamr@2: class MCTTokenObject 
williamr@2: 	{
williamr@2: public:
williamr@2: 	/** 
williamr@2: 	 * Releases the MCTTokenObject object.
williamr@2: 	 *
williamr@2: 	 * To be called when you have finished with the object. 
williamr@2: 	 */
williamr@2: 	IMPORT_C void Release();
williamr@2: 
williamr@2: 	/** 
williamr@2: 	 * Gets the object's human-readable label.	
williamr@2: 	 *
williamr@2: 	 * @return	A human-readable label of the object. 
williamr@2: 	 */
williamr@2: 	virtual const TDesC& Label() const = 0;
williamr@2: 	
williamr@2: 	/** 
williamr@2: 	 * Gets a reference to the associated token.
williamr@2: 	 *
williamr@2: 	 * @return	The associated token. 
williamr@2: 	 */
williamr@2: 	virtual MCTToken& Token() const = 0;
williamr@2: 
williamr@2: 	/** 
williamr@2: 	 * Gets the UID representing the type of the token object.
williamr@2: 	 *
williamr@2: 	 * The meanings of possible UIDs should be documented in the documentation for 
williamr@2: 	 * the interface that returns them.
williamr@2: 	 *
williamr@2: 	 * @return	The UID representing the type of the token object. 
williamr@2: 	 */
williamr@2: 	virtual TUid Type() const = 0;
williamr@2: 
williamr@2: 	/** 
williamr@2: 	 * Gets a handle for the object.
williamr@2: 	 *
williamr@2: 	 * The primary purpose of the handle is to allow token objects to be 'passed' 
williamr@2: 	 * between processes. 
williamr@2: 	 *
williamr@2: 	 * @see TCTTokenObjectHandle for more details. 
williamr@2: 	 * @return	The handle of the Token Object. 
williamr@2: 	 */
williamr@2: 	virtual TCTTokenObjectHandle Handle() const = 0;
williamr@2:  protected:
williamr@2: 	/** 
williamr@2: 	 * Releases the object once the base-class framework work has been done.
williamr@2: 	 * 
williamr@2: 	 * The default implementation simply does a 'delete this', but derived classes 
williamr@2: 	 * can substitute their own behaviour; for instance, to implement reference counting 
williamr@2: 	 * of the token objects themselves. 
williamr@2: 	 */
williamr@2: 	IMPORT_C virtual void DoRelease();
williamr@2: 
williamr@2: 	/**
williamr@2: 	 * Constructor. This needs a token in order to increment the
williamr@2: 	 * token's reference count. 
williamr@2: 	 * 
williamr@2: 	 * @param aToken	The associated token.
williamr@2: 	 */
williamr@2: 	IMPORT_C MCTTokenObject(MCTToken& aToken);
williamr@2: 
williamr@2: 	/** This destructor is protected as clients should use Release() instead. 
williamr@2: 	*/
williamr@2: 	inline virtual ~MCTTokenObject() = 0;
williamr@2: 
williamr@2: 	/** 
williamr@2: 	 * Increments the token's reference count by one.  
williamr@2: 	 * 
williamr@2: 	 * This is neccessary to allow derived classes to implement their own 
williamr@2: 	 * reference counting, as Release() automatically call Release() on the token. 
williamr@2: 	 */
williamr@2: 	IMPORT_C void AddTokenRef();
williamr@2: 	};
williamr@2: 
williamr@2: /** 
williamr@2:  * Destructor.
williamr@2:  *
williamr@2:  * Frees all resources owned by the object, prior to its destruction. 
williamr@2:  */
williamr@2: inline MCTTokenObject::~MCTTokenObject()
williamr@2: 	{
williamr@2: 	}
williamr@2: 
williamr@2: #endif