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