2 * Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
28 #ifndef __MCTTOKENOBJECT_H__
29 #define __MCTTOKENOBJECT_H__
34 * The base class for all token objects.
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.)
50 * Releases the MCTTokenObject object.
52 * To be called when you have finished with the object.
54 IMPORT_C void Release();
57 * Gets the object's human-readable label.
59 * @return A human-readable label of the object.
61 virtual const TDesC& Label() const = 0;
64 * Gets a reference to the associated token.
66 * @return The associated token.
68 virtual MCTToken& Token() const = 0;
71 * Gets the UID representing the type of the token object.
73 * The meanings of possible UIDs should be documented in the documentation for
74 * the interface that returns them.
76 * @return The UID representing the type of the token object.
78 virtual TUid Type() const = 0;
81 * Gets a handle for the object.
83 * The primary purpose of the handle is to allow token objects to be 'passed'
86 * @see TCTTokenObjectHandle for more details.
87 * @return The handle of the Token Object.
89 virtual TCTTokenObjectHandle Handle() const = 0;
92 * Releases the object once the base-class framework work has been done.
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.
98 IMPORT_C virtual void DoRelease();
101 * Constructor. This needs a token in order to increment the
102 * token's reference count.
104 * @param aToken The associated token.
106 IMPORT_C MCTTokenObject(MCTToken& aToken);
108 /** This destructor is protected as clients should use Release() instead.
110 inline virtual ~MCTTokenObject() = 0;
113 * Increments the token's reference count by one.
115 * This is neccessary to allow derived classes to implement their own
116 * reference counting, as Release() automatically call Release() on the token.
118 IMPORT_C void AddTokenRef();
124 * Frees all resources owned by the object, prior to its destruction.
126 inline MCTTokenObject::~MCTTokenObject()