author | William Roberts <williamr@symbian.org> |
Wed, 31 Mar 2010 12:33:34 +0100 | |
branch | Symbian3 |
changeset 4 | 837f303aceeb |
parent 2 | 2fe1408b6811 |
permissions | -rw-r--r-- |
williamr@2 | 1 |
/* |
williamr@2 | 2 |
* Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). |
williamr@2 | 3 |
* All rights reserved. |
williamr@2 | 4 |
* This component and the accompanying materials are made available |
williamr@2 | 5 |
* under the terms of the License "Eclipse Public License v1.0" |
williamr@2 | 6 |
* which accompanies this distribution, and is available |
williamr@2 | 7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
williamr@2 | 8 |
* |
williamr@2 | 9 |
* Initial Contributors: |
williamr@2 | 10 |
* Nokia Corporation - initial contribution. |
williamr@2 | 11 |
* |
williamr@2 | 12 |
* Contributors: |
williamr@2 | 13 |
* |
williamr@2 | 14 |
* Description: |
williamr@2 | 15 |
* |
williamr@2 | 16 |
*/ |
williamr@2 | 17 |
|
williamr@2 | 18 |
|
williamr@2 | 19 |
/** |
williamr@2 | 20 |
@file |
williamr@4 | 21 |
@publishedAll |
williamr@2 | 22 |
@released |
williamr@2 | 23 |
*/ |
williamr@2 | 24 |
|
williamr@2 | 25 |
|
williamr@2 | 26 |
#ifndef __MCTTOKENOBJECT_H__ |
williamr@2 | 27 |
#define __MCTTOKENOBJECT_H__ |
williamr@2 | 28 |
|
williamr@2 | 29 |
class MCTToken; |
williamr@2 | 30 |
|
williamr@2 | 31 |
/** |
williamr@2 | 32 |
* The base class for all token objects. |
williamr@2 | 33 |
* |
williamr@2 | 34 |
* Any object representing something managed via a particular token interface |
williamr@2 | 35 |
* should be derived from this class. It provides certain common attributes that |
williamr@2 | 36 |
* all objects must have (e.g. Label, Type, Token, Handle) and code to interact |
williamr@2 | 37 |
* with the token's reference counting code. Token objects themselves are not |
williamr@2 | 38 |
* reference counted, but the token will not be closed while token objects from |
williamr@2 | 39 |
* it remain in existence. (Token objects can implement their own reference counting |
williamr@2 | 40 |
* framework if required.) |
williamr@2 | 41 |
* |
williamr@2 | 42 |
* @since v7.0 |
williamr@2 | 43 |
*/ |
williamr@2 | 44 |
class MCTTokenObject |
williamr@2 | 45 |
{ |
williamr@2 | 46 |
public: |
williamr@2 | 47 |
/** |
williamr@2 | 48 |
* Releases the MCTTokenObject object. |
williamr@2 | 49 |
* |
williamr@2 | 50 |
* To be called when you have finished with the object. |
williamr@2 | 51 |
*/ |
williamr@2 | 52 |
IMPORT_C void Release(); |
williamr@2 | 53 |
|
williamr@2 | 54 |
/** |
williamr@2 | 55 |
* Gets the object's human-readable label. |
williamr@2 | 56 |
* |
williamr@2 | 57 |
* @return A human-readable label of the object. |
williamr@2 | 58 |
*/ |
williamr@2 | 59 |
virtual const TDesC& Label() const = 0; |
williamr@2 | 60 |
|
williamr@2 | 61 |
/** |
williamr@2 | 62 |
* Gets a reference to the associated token. |
williamr@2 | 63 |
* |
williamr@2 | 64 |
* @return The associated token. |
williamr@2 | 65 |
*/ |
williamr@2 | 66 |
virtual MCTToken& Token() const = 0; |
williamr@2 | 67 |
|
williamr@2 | 68 |
/** |
williamr@2 | 69 |
* Gets the UID representing the type of the token object. |
williamr@2 | 70 |
* |
williamr@2 | 71 |
* The meanings of possible UIDs should be documented in the documentation for |
williamr@2 | 72 |
* the interface that returns them. |
williamr@2 | 73 |
* |
williamr@2 | 74 |
* @return The UID representing the type of the token object. |
williamr@2 | 75 |
*/ |
williamr@2 | 76 |
virtual TUid Type() const = 0; |
williamr@2 | 77 |
|
williamr@2 | 78 |
/** |
williamr@2 | 79 |
* Gets a handle for the object. |
williamr@2 | 80 |
* |
williamr@2 | 81 |
* The primary purpose of the handle is to allow token objects to be 'passed' |
williamr@2 | 82 |
* between processes. |
williamr@2 | 83 |
* |
williamr@2 | 84 |
* @see TCTTokenObjectHandle for more details. |
williamr@2 | 85 |
* @return The handle of the Token Object. |
williamr@2 | 86 |
*/ |
williamr@2 | 87 |
virtual TCTTokenObjectHandle Handle() const = 0; |
williamr@2 | 88 |
protected: |
williamr@2 | 89 |
/** |
williamr@2 | 90 |
* Releases the object once the base-class framework work has been done. |
williamr@2 | 91 |
* |
williamr@2 | 92 |
* The default implementation simply does a 'delete this', but derived classes |
williamr@2 | 93 |
* can substitute their own behaviour; for instance, to implement reference counting |
williamr@2 | 94 |
* of the token objects themselves. |
williamr@2 | 95 |
*/ |
williamr@2 | 96 |
IMPORT_C virtual void DoRelease(); |
williamr@2 | 97 |
|
williamr@2 | 98 |
/** |
williamr@2 | 99 |
* Constructor. This needs a token in order to increment the |
williamr@2 | 100 |
* token's reference count. |
williamr@2 | 101 |
* |
williamr@2 | 102 |
* @param aToken The associated token. |
williamr@2 | 103 |
*/ |
williamr@2 | 104 |
IMPORT_C MCTTokenObject(MCTToken& aToken); |
williamr@2 | 105 |
|
williamr@2 | 106 |
/** This destructor is protected as clients should use Release() instead. |
williamr@2 | 107 |
*/ |
williamr@2 | 108 |
inline virtual ~MCTTokenObject() = 0; |
williamr@2 | 109 |
|
williamr@2 | 110 |
/** |
williamr@2 | 111 |
* Increments the token's reference count by one. |
williamr@2 | 112 |
* |
williamr@2 | 113 |
* This is neccessary to allow derived classes to implement their own |
williamr@2 | 114 |
* reference counting, as Release() automatically call Release() on the token. |
williamr@2 | 115 |
*/ |
williamr@2 | 116 |
IMPORT_C void AddTokenRef(); |
williamr@2 | 117 |
}; |
williamr@2 | 118 |
|
williamr@2 | 119 |
/** |
williamr@2 | 120 |
* Destructor. |
williamr@2 | 121 |
* |
williamr@2 | 122 |
* Frees all resources owned by the object, prior to its destruction. |
williamr@2 | 123 |
*/ |
williamr@2 | 124 |
inline MCTTokenObject::~MCTTokenObject() |
williamr@2 | 125 |
{ |
williamr@2 | 126 |
} |
williamr@2 | 127 |
|
williamr@2 | 128 |
#endif |