lowlevellibsandfws/pluginfw/Framework/Example/exampleEight.cpp
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // The implementation of a some classes
       
    15 // to be provided by ECom.
       
    16 // 1. Using the CExampleInterface class as a base.
       
    17 // 
       
    18 //
       
    19 
       
    20 #include "Interface.h"
       
    21 #include "ImplementationProxy.h"
       
    22 #include "TestUtilities.h"	// For __FILE__LINE__
       
    23 
       
    24 // ____________________________________________________________________________
       
    25 // 
       
    26 /**
       
    27 	Intended usage: This class implements the functionality promised by 
       
    28 	the CExampleInterface defintion class. It does little apart from provides a test instance
       
    29 	which may be retrieved and run for testing purposes.
       
    30 	Its resolution is based upon its registered default data string that
       
    31 	advertises this class as being able to handle 'text\wml' data.
       
    32 	@since 7.0
       
    33 
       
    34  */
       
    35 class CImplementationClassEight : public CExampleInterface
       
    36 {
       
    37 // Methods
       
    38 public:
       
    39 /**
       
    40 	@fn				NewL(TAny* aInitParams)
       
    41 	Intended Usage	: Standardised safe construction which leaves nothing the cleanup stack.
       
    42 	Error Condition	: Leaves with error code.
       
    43 	@leave          KErrNoMemory.
       
    44 	@since			7.0
       
    45 	@param			aInitParams The parameter struct used for initialising this object
       
    46 	@return			CImplementationClassEight* The class instance.
       
    47 	@pre 			None
       
    48 	@post			CImplementationClassEight has been constructed,
       
    49 					and initialised.
       
    50  */
       
    51 	static CImplementationClassEight* NewL(TAny* aInitParams);
       
    52 
       
    53 /**
       
    54 	@fn				~CImplementationClassEight()
       
    55 	Intended Usage	: Default Destructor	
       
    56 	Error Condition	: None	
       
    57 	@since			7.0
       
    58 	@pre 			CImplementationClassEight has been constructed
       
    59 	@post			CImplementationClassEight has been completely destroyed.
       
    60  */
       
    61 	virtual ~CImplementationClassEight();
       
    62 
       
    63 /**
       
    64 	@fn				DoMethodL()
       
    65 	Intended Usage	: Overload of the pure interface method
       
    66 					Representative of a method provided on 
       
    67 					the interface by the interface definer.
       
    68 	Error Condition	: Leaves with an error code.
       
    69 	@leave  		KErrNoMemory, KErrNotSupported.
       
    70 	@since			7.0
       
    71 	@return			None
       
    72 	@pre 			CImplementationClassEight has been constructed
       
    73 	@post			Unspecified
       
    74  */	
       
    75 	void DoMethodL();
       
    76 
       
    77 /**
       
    78 	@fn				FireAndForget()
       
    79 	Intended Usage	: Overload of the pure interface method
       
    80 					asynchronous function which 
       
    81 					an interface definer could specify.  
       
    82 					It allows the client to call the function in the knowledge 
       
    83 					that the object will commit suicide when the 
       
    84 					function completes.
       
    85 	Error Condition	: None.
       
    86 	@since			7.0
       
    87 	@return			TInt KErrNone for success.
       
    88 	@pre 			CImplementationClassEight has been constructed
       
    89 	@post			Unspecified
       
    90  */
       
    91 	TInt FireAndForget();
       
    92 
       
    93  /**
       
    94 	@fn				ImplId()
       
    95 	Intended Usage	: To verify the object returned by ECOM.
       
    96 	Error Condition	: None.
       
    97 	@since			7.0
       
    98 	@return			TUid (ECOM's Implementation Uid for this class.)
       
    99 	@pre 			CImplementationClassThree has been constructed
       
   100 	@post			Unspecified
       
   101  */
       
   102 	TUid ImplId();
       
   103 
       
   104 private:
       
   105 /**
       
   106 	@fn				CImplementationClassEight()
       
   107 	Intended Usage	: Default Constructor : usable only by derived classes	
       
   108 	Error Condition	: None	
       
   109 	@since			7.0
       
   110 	@pre 			None
       
   111 	@post			CImplementationClassEight has been constructed
       
   112  */
       
   113 	CImplementationClassEight();
       
   114 
       
   115 /**
       
   116 	@fn				ConstructL(TAny* aInitParams)
       
   117 	Intended Usage	: Completes the safe construction of the CImplementationClassEight object
       
   118 	Error Condition	: Leaves with the error code.	
       
   119 	@leave          KErrNoMemory.	
       
   120 	@since			7.0
       
   121 	@param			aInitParams The parameter struct used for initialising this object
       
   122 	@pre 			CImplementationClassEight has been constructed
       
   123 	@post			CImplementationClassEight has been fully initialised.
       
   124  */
       
   125 	void ConstructL(TAny* aInitParams);
       
   126 
       
   127 // Provide the CActive overloads
       
   128 	void RunL();
       
   129 	void DoCancel();
       
   130 	TInt RunError(TInt aError);
       
   131 
       
   132 private:
       
   133 /** A place for allocating some memory in the ConstructL */
       
   134 	HBufC*	iInternalDescriptor;
       
   135 /** An int to be stored in TLS to test its useage */	
       
   136 	TInt	iTLSInt;
       
   137 
       
   138 };  // End of CImplementationClassEight definition
       
   139 
       
   140 // __________________________________________________________________________
       
   141 // Implementation
       
   142 
       
   143 CImplementationClassEight* CImplementationClassEight::NewL(TAny* aInitParams)
       
   144 // Intended Usage	: Safe construction which leaves nothing upon the cleanup stack	
       
   145 // Error Condition	: Will leave with an appropriate error code	
       
   146 // Dependencies	: CBase
       
   147 // @param			" "
       
   148 // @return			CImplementationClassEight* a pointer to the fully instantiated CImplementationClassEight object
       
   149 // @pre 			None
       
   150 // @post			The object has been fully instantiated
       
   151 // Static member
       
   152 	{
       
   153 	CImplementationClassEight* self=new(ELeave) CImplementationClassEight();  // calls c'tor
       
   154 	CleanupStack::PushL(self);	// Make the construction safe by using the cleanup stack
       
   155 	self->ConstructL(aInitParams); // Complete the 'construction'.
       
   156 	CleanupStack::Pop(self);
       
   157 	return self;
       
   158 	}
       
   159 
       
   160 CImplementationClassEight::~CImplementationClassEight()
       
   161 // Default virtual d'tor
       
   162 	{
       
   163 	delete iInternalDescriptor;
       
   164 	}
       
   165 
       
   166 CImplementationClassEight::CImplementationClassEight()
       
   167 // Default c'tor for use by derived and 
       
   168 // static construction methods only
       
   169 : CExampleInterface()
       
   170 	{
       
   171 	// Deliberately do nothing here : See ConstructL() for initialisation completion.
       
   172 	}
       
   173 
       
   174 void CImplementationClassEight::ConstructL(TAny*)
       
   175 // Intended Usage	: Safely complete the initialization of the constructed object	
       
   176 // Error Condition	: Will leave with an appropriate error code	
       
   177 // Dependencies	: CBase
       
   178 // @return			void
       
   179 // @pre 			CImplementationClassEight has been constructed
       
   180 // @post			The CImplementationClassEight object has been fully instantiated
       
   181 //
       
   182 	{
       
   183 	}
       
   184 
       
   185 void CImplementationClassEight::DoMethodL()
       
   186 	{
       
   187 	// Access TLS to ensure it has been set properly
       
   188 	REINTERPRET_CAST(TInt*, Dll::Tls());
       
   189 	}
       
   190 
       
   191 TInt CImplementationClassEight::FireAndForget()
       
   192 	{
       
   193 	TRAPD(error,DoMethodL());
       
   194 	return error;			// Always KErrNotSupported
       
   195 	}
       
   196 
       
   197 // Provide the CActive overloads
       
   198 void CImplementationClassEight::RunL()
       
   199 	{
       
   200 	// Do nothing : should never be called
       
   201 	__ASSERT_DEBUG(EFalse,User::Invariant());
       
   202 	}
       
   203 
       
   204 void CImplementationClassEight::DoCancel()
       
   205 	{
       
   206 	// Do nothing
       
   207 	}
       
   208 
       
   209 TInt CImplementationClassEight::RunError(TInt /*aError*/)
       
   210 	{
       
   211 	return KErrNone;
       
   212 	}
       
   213 
       
   214 TUid CImplementationClassEight::ImplId()
       
   215 	{
       
   216 	TUid idVal = {0x10009DBD};
       
   217 	return (idVal);
       
   218 	}
       
   219 
       
   220 // __________________________________________________________________________
       
   221 // Exported proxy for instantiation method resolution
       
   222 // Define the interface UIDs
       
   223 const TImplementationProxy ImplementationTable[] = 
       
   224 	{
       
   225 		IMPLEMENTATION_PROXY_ENTRY(0x10009DBD,	CImplementationClassEight::NewL)
       
   226 	};
       
   227 
       
   228 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
       
   229 	{
       
   230 	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
       
   231 	return ImplementationTable;
       
   232 	}
       
   233