1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/ct/ccttokentype.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -0,0 +1,182 @@
1.4 +/*
1.5 +* Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +* CTTokenType Codes
1.19 +*
1.20 +*/
1.21 +
1.22 +
1.23 +
1.24 +
1.25 +/**
1.26 + @file
1.27 + @internalTechnology
1.28 +*/
1.29 +
1.30 +#ifndef __CCTTOKENTYPE_H__
1.31 +#define __CCTTOKENTYPE_H__
1.32 +
1.33 +#include <ct/mcttokentype.h>
1.34 +
1.35 +/**
1.36 + * Abstract base class for a handler object to be called when a CCTTokenType is
1.37 + * deleted. The handler is called simply by being deleted. It is called from
1.38 + * CCTTokenType's destructor.
1.39 + *
1.40 + * This allows for ecom-loaded tokens to be destroyed properly without
1.41 + * forcing clients of ctframework.dll to link against ecom.
1.42 + *
1.43 + * @internalTechnology
1.44 + */
1.45 +class CCTTokenTypeDeleteHandler : public CBase
1.46 + {
1.47 + public:
1.48 + IMPORT_C virtual ~CCTTokenTypeDeleteHandler();
1.49 + };
1.50 +
1.51 +/**
1.52 + * A token type.
1.53 + *
1.54 + * This abstract class is instantiated using the ECom plug-in architecture
1.55 + * for a particular token type. This adds a delayed destruction behaviour
1.56 + * to MCTTokenType, which defines the majority of the interface.
1.57 + *
1.58 + * This class uses protected inheritance from CBase so that clients cannot
1.59 + * inadvertantly call delete on instances of it - they should call the Release()
1.60 + * method instead.
1.61 + *
1.62 + * @publishedPartner
1.63 + * @released
1.64 + * @since v7.0
1.65 + */
1.66 +class CCTTokenType : protected CBase, public MCTTokenType
1.67 + {
1.68 +public:
1.69 + /** Gets a file server session */
1.70 + inline RFs& Fs();
1.71 +
1.72 +protected:
1.73 + /** Increments the reference count.
1.74 + *
1.75 + * Must be called for every token created from this interface */
1.76 + IMPORT_C void IncReferenceCount();
1.77 +
1.78 + // From this point onwards, everything in this class is essentialy
1.79 + // internal and of no interest to dereived classes.
1.80 + public:
1.81 +
1.82 + /** Creates a CCTTokenType given its CCTTokenTypeInfo.
1.83 + *
1.84 + * Static constructor function that uses the ECom
1.85 + * plug-in architecture to load the actual implementation.
1.86 + *
1.87 + * @param aInfo Information about the token type.
1.88 + * @param aFs An open file server session.
1.89 + * @return The new token type object. */
1.90 + IMPORT_C static CCTTokenType* NewL(const CCTTokenTypeInfo& aInfo, RFs aFs);
1.91 +
1.92 + /** Creates a CCTTokenType given the UID of the token type.
1.93 + *
1.94 + * Static constructor function that uses the ECom
1.95 + * plug-in architecture to load the actual implementation.
1.96 + *
1.97 + * @param aUID The UID of the token type.
1.98 + * @param aFs An open file server session.
1.99 + * @return The new token type object. */
1.100 + IMPORT_C static CCTTokenType* NewL(TUid aUID, RFs aFs);
1.101 +
1.102 + /** Releases the token type object.
1.103 + *
1.104 + * To be called when you have finished with the object.
1.105 + *
1.106 + * The API does not allow the destructor to be directly called as this object
1.107 + * could remain in existence for longer to hold onto the ECom handle on the DLL;
1.108 + * for instance it may not be deleted until all tokens and interfaces have also
1.109 + * been released. */
1.110 + IMPORT_C virtual void Release();
1.111 +
1.112 + /** Gets the UID of the token type.
1.113 + *
1.114 + * @return The UID of the token type. */
1.115 + IMPORT_C virtual TUid Type() const;
1.116 +
1.117 + /** Gets the label of the token type.
1.118 + *
1.119 + * @return The label of the token type. */
1.120 + IMPORT_C virtual const TDesC& Label() const;
1.121 +
1.122 + protected:
1.123 + IMPORT_C CCTTokenType();
1.124 +
1.125 + /** Destructor */
1.126 + IMPORT_C virtual ~CCTTokenType();
1.127 +
1.128 + /**
1.129 + * For 2 phase construction.
1.130 + *
1.131 + * This function must be called by derived NewL() functions if and only if the
1.132 + * class is being constructed without using ECom.
1.133 + */
1.134 + IMPORT_C void ConstructL(TUid aUID, const TDesC& aLabel, RFs aFs);
1.135 +
1.136 + private:
1.137 + static CCTTokenType* CreateTokenTypeLC(TUid aUid);
1.138 +
1.139 + private:
1.140 + /// Delete handler, called on destruction
1.141 + CCTTokenTypeDeleteHandler* iDeleteHandler;
1.142 +
1.143 + /// A refedrence count
1.144 + TInt iCount;
1.145 +
1.146 + /// The UID of the token type.
1.147 + TUid iUID;
1.148 +
1.149 + /// The label of the token type
1.150 + HBufC* iLabel;
1.151 +
1.152 + RFs iFs;
1.153 + };
1.154 +
1.155 +inline RFs& CCTTokenType::Fs()
1.156 + /** Gets the file server session.
1.157 + *
1.158 + * @return The file server session. */
1.159 + {
1.160 + return iFs;
1.161 + }
1.162 +
1.163 +// These are defined here as they need to ahve both MCTTokenType and
1.164 +// CCTTokenType defined before they can be.
1.165 +inline MCTTokenType* MCTTokenType::NewL(const CCTTokenTypeInfo& aInfo, RFs aFs)
1.166 + /** Creates a MCTTokenType object given it's CCTTokenTypeInfo.
1.167 + *
1.168 + * @param aInfo Information about the token type.
1.169 + * @param aFs An open file server session.
1.170 + * @return A new token type object. */
1.171 + {
1.172 + return CCTTokenType::NewL(aInfo, aFs);
1.173 + }
1.174 +
1.175 +inline MCTTokenType* MCTTokenType::NewL(TUid aUID, RFs aFs)
1.176 + /** Creates a MCTTokenType object given the UID of the token type.
1.177 + *
1.178 + * @param aUID The UID of the token type.
1.179 + * @param aFs An open file server session.
1.180 + * @return A new token type object. */
1.181 + {
1.182 + return CCTTokenType::NewL(aUID, aFs);
1.183 + }
1.184 +
1.185 +#endif //__CCTTOKENTYPE_H__