epoc32/include/ct/ccttokentype.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
child 4 837f303aceeb
permissions -rw-r--r--
Final list of Symbian^2 public API header files
     1 /*
     2 * Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     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".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 * CTTokenType Codes
    16 *
    17 */
    18 
    19 
    20 
    21 
    22 /**
    23  @file 
    24  @internalTechnology
    25 */
    26  
    27 #ifndef __CCTTOKENTYPE_H__
    28 #define __CCTTOKENTYPE_H__
    29 
    30 #include <ct/mcttokentype.h>
    31 
    32 /**
    33  * Abstract base class for a handler object to be called when a CCTTokenType is
    34  * deleted.  The handler is called simply by being deleted.  It is called from
    35  * CCTTokenType's destructor.
    36  *
    37  * This allows for ecom-loaded tokens to be destroyed properly without
    38  * forcing clients of ctframework.dll to link against ecom.
    39  *
    40  * @internalTechnology
    41  */
    42 class CCTTokenTypeDeleteHandler : public CBase
    43 	{
    44  public:
    45 	IMPORT_C virtual ~CCTTokenTypeDeleteHandler();
    46 	};
    47 
    48 /**
    49  * A token type.
    50  *
    51  * This abstract class is instantiated using the ECom plug-in architecture 
    52  * for a particular token type. This adds a delayed destruction behaviour 
    53  * to MCTTokenType, which defines the majority of the interface.
    54  *
    55  * This class uses protected inheritance from CBase so that clients cannot
    56  * inadvertantly call delete on instances of it - they should call the Release()
    57  * method instead.
    58  * 
    59  * @publishedPartner
    60  * @released
    61  * @since v7.0
    62  */
    63 class CCTTokenType : protected CBase, public MCTTokenType
    64 	{
    65 public:
    66 	/** Gets a file server session */
    67 	inline RFs& Fs();
    68 
    69 protected:
    70 	/** Increments the reference count. 
    71 	* 
    72 	* Must be called for every token created from this interface */
    73 	IMPORT_C void IncReferenceCount();
    74 
    75 	// From this point onwards, everything in this class is essentialy
    76 	// internal and of no interest to dereived classes.
    77  public:
    78 	
    79 	/** Creates a CCTTokenType given its CCTTokenTypeInfo.
    80 	*	
    81 	* Static constructor function that uses the ECom 
    82 	* plug-in architecture to load the actual implementation.
    83 	*
    84 	* @param aInfo	Information about the token type.
    85 	* @param aFs	An open file server session.
    86 	* @return		The new token type object. */
    87 	IMPORT_C static CCTTokenType* NewL(const CCTTokenTypeInfo& aInfo, RFs aFs);
    88 
    89 	/** Creates a CCTTokenType given the UID of the token type.	
    90 	*
    91 	* Static constructor function that uses the ECom 
    92 	* plug-in architecture to load the actual implementation.
    93 	*
    94 	* @param aUID	The UID of the token type.
    95 	* @param aFs	An open file server session.
    96 	* @return		The new token type object. */
    97 	IMPORT_C static CCTTokenType* NewL(TUid aUID, RFs aFs);
    98 	
    99 	/** Releases the token type object.
   100 	*
   101 	* To be called when you have finished with the object.
   102 	*
   103 	* The API does not allow the destructor to be directly called as this object 
   104 	* could remain in existence for longer to hold onto the ECom handle on the DLL; 
   105 	* for instance it may not be deleted until all tokens and interfaces have also 
   106 	* been released. */
   107 	IMPORT_C virtual void Release();
   108 
   109 	/** Gets the UID of the token type.	
   110 	*
   111 	* @return	The UID of the token type. */
   112 	IMPORT_C virtual TUid Type() const;
   113 	
   114 	/** Gets the label of the token type.	
   115 	*
   116 	* @return	The label of the token type. */
   117 	IMPORT_C virtual const TDesC& Label() const;
   118 
   119  protected:
   120 	IMPORT_C CCTTokenType();
   121 
   122 	/** Destructor */
   123 	IMPORT_C virtual ~CCTTokenType();
   124 
   125 	/**
   126 	 * For 2 phase construction. 
   127 	 *
   128 	 * This function must be called by derived NewL() functions if and only if the 
   129 	 * class is being constructed without using ECom.
   130 	 */
   131 	IMPORT_C void ConstructL(TUid aUID, const TDesC& aLabel, RFs aFs);
   132 
   133  private:
   134 	static CCTTokenType* CreateTokenTypeLC(TUid aUid);	
   135 
   136  private:
   137 	/// Delete handler, called on destruction
   138 	CCTTokenTypeDeleteHandler* iDeleteHandler;
   139 	
   140 	/// A refedrence count
   141 	TInt iCount;
   142 
   143 	/// The UID of the token type.
   144 	TUid iUID;
   145 
   146 	/// The label of the token type
   147 	HBufC* iLabel;
   148 
   149 	RFs iFs;
   150 	};
   151 
   152 inline RFs& CCTTokenType::Fs()
   153 	/** Gets the file server session.
   154 	*
   155 	* @return	The file server session. */
   156 	{
   157 	return iFs;
   158 	}
   159 
   160 // These are defined here as they need to ahve both MCTTokenType and 
   161 // CCTTokenType defined before they can be.
   162 inline MCTTokenType* MCTTokenType::NewL(const CCTTokenTypeInfo& aInfo, RFs aFs)
   163 	/** Creates a MCTTokenType object given it's CCTTokenTypeInfo.
   164 	*
   165 	* @param aInfo	Information about the token type.
   166 	* @param aFs	An open file server session.
   167 	* @return		A new token type object. */
   168 	{
   169 	return CCTTokenType::NewL(aInfo, aFs);
   170 	}
   171 
   172 inline MCTTokenType* MCTTokenType::NewL(TUid aUID, RFs aFs)
   173 	/** Creates a MCTTokenType object given the UID of the token type. 
   174 	*
   175 	* @param aUID	The UID of the token type.
   176 	* @param aFs	An open file server session.
   177 	* @return		A new token type object. */
   178 	{
   179 	return CCTTokenType::NewL(aUID, aFs);
   180 	}
   181 
   182 #endif //__CCTTOKENTYPE_H__