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.
26 #ifndef __MCTTOKENOBJECT_H__
27 #define __MCTTOKENOBJECT_H__
32 * The base class for all token objects.
34 * Any object representing something managed via a particular token interface
35 * should be derived from this class. It provides certain common attributes that
36 * all objects must have (e.g. Label, Type, Token, Handle) and code to interact
37 * with the token's reference counting code. Token objects themselves are not
38 * reference counted, but the token will not be closed while token objects from
39 * it remain in existence. (Token objects can implement their own reference counting
40 * framework if required.)
48 * Releases the MCTTokenObject object.
50 * To be called when you have finished with the object.
52 IMPORT_C void Release();
55 * Gets the object's human-readable label.
57 * @return A human-readable label of the object.
59 virtual const TDesC& Label() const = 0;
62 * Gets a reference to the associated token.
64 * @return The associated token.
66 virtual MCTToken& Token() const = 0;
69 * Gets the UID representing the type of the token object.
71 * The meanings of possible UIDs should be documented in the documentation for
72 * the interface that returns them.
74 * @return The UID representing the type of the token object.
76 virtual TUid Type() const = 0;
79 * Gets a handle for the object.
81 * The primary purpose of the handle is to allow token objects to be 'passed'
84 * @see TCTTokenObjectHandle for more details.
85 * @return The handle of the Token Object.
87 virtual TCTTokenObjectHandle Handle() const = 0;
90 * Releases the object once the base-class framework work has been done.
92 * The default implementation simply does a 'delete this', but derived classes
93 * can substitute their own behaviour; for instance, to implement reference counting
94 * of the token objects themselves.
96 IMPORT_C virtual void DoRelease();
99 * Constructor. This needs a token in order to increment the
100 * token's reference count.
102 * @param aToken The associated token.
104 IMPORT_C MCTTokenObject(MCTToken& aToken);
106 /** This destructor is protected as clients should use Release() instead.
108 inline virtual ~MCTTokenObject() = 0;
111 * Increments the token's reference count by one.
113 * This is neccessary to allow derived classes to implement their own
114 * reference counting, as Release() automatically call Release() on the token.
116 IMPORT_C void AddTokenRef();
122 * Frees all resources owned by the object, prior to its destruction.
124 inline MCTTokenObject::~MCTTokenObject()