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