lowlevellibsandfws/pluginfw/Framework/Example/ExampleSix.cpp
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 // Copyright (c) 2005-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 CImplementationClassSix : 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			CImplementationClassSix* The class instance.
       
    47 	@pre 			None
       
    48 	@post			CImplementationClassSix has been constructed,
       
    49 					and initialised.
       
    50  */
       
    51 	static CImplementationClassSix* NewL(TAny* aInitParams);
       
    52 
       
    53 /**
       
    54 	@fn				~CImplementationClassSix()
       
    55 	Intended Usage	: Default Destructor	
       
    56 	Error Condition	: None	
       
    57 	@since			7.0
       
    58 	@pre 			CImplementationClassSix has been constructed
       
    59 	@post			CImplementationClassSix has been completely destroyed.
       
    60  */
       
    61 	virtual ~CImplementationClassSix();
       
    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 			CImplementationClassSix 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 			CImplementationClassSix 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				CImplementationClassSix()
       
   107 	Intended Usage	: Default Constructor : usable only by derived classes	
       
   108 	Error Condition	: None	
       
   109 	@since			7.0
       
   110 	@pre 			None
       
   111 	@post			CImplementationClassSix has been constructed
       
   112  */
       
   113 	CImplementationClassSix();
       
   114 
       
   115 /**
       
   116 	@fn				ConstructL(TAny* aInitParams)
       
   117 	Intended Usage	: Completes the safe construction of the CImplementationClassSix 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 			CImplementationClassSix has been constructed
       
   123 	@post			CImplementationClassSix 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 CImplementationClassSix definition
       
   139 
       
   140 // __________________________________________________________________________
       
   141 // Implementation
       
   142 
       
   143 CImplementationClassSix* CImplementationClassSix::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			CImplementationClassSix* a pointer to the fully instantiated CImplementationClassSix object
       
   149 // @pre 			None
       
   150 // @post			The object has been fully instantiated
       
   151 // Static member
       
   152 	{
       
   153 	CImplementationClassSix* self=new(ELeave) CImplementationClassSix();  // 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 CImplementationClassSix::~CImplementationClassSix()
       
   161 // Default virtual d'tor
       
   162 	{
       
   163 	delete iInternalDescriptor;
       
   164 	}
       
   165 
       
   166 CImplementationClassSix::CImplementationClassSix()
       
   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 CImplementationClassSix::ConstructL(TAny* aInitParams)
       
   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 			CImplementationClassSix has been constructed
       
   180 // @post			The CImplementationClassSix object has been fully instantiated
       
   181 //
       
   182 	{
       
   183 	TExampleInterfaceInitParams* params = REINTERPRET_CAST(TExampleInterfaceInitParams*,
       
   184 														   aInitParams);
       
   185 	if(params->descriptor)
       
   186 		iInternalDescriptor = params->descriptor->AllocL();
       
   187 
       
   188 	Dll::SetTls(&iTLSInt);
       
   189 	}
       
   190 
       
   191 void CImplementationClassSix::DoMethodL()
       
   192 	{
       
   193 	// Access TLS to ensure it has been set properly
       
   194 	REINTERPRET_CAST(TInt*, Dll::Tls());
       
   195 	}
       
   196 
       
   197 TInt CImplementationClassSix::FireAndForget()
       
   198 	{
       
   199 	TRAPD(error,DoMethodL());
       
   200 	return error;			// Always KErrNotSupported
       
   201 	}
       
   202 
       
   203 // Provide the CActive overloads
       
   204 void CImplementationClassSix::RunL()
       
   205 	{
       
   206 	// Do nothing : should never be called
       
   207 	__ASSERT_DEBUG(EFalse,User::Invariant());
       
   208 	}
       
   209 
       
   210 void CImplementationClassSix::DoCancel()
       
   211 	{
       
   212 	// Do nothing
       
   213 	}
       
   214 
       
   215 TInt CImplementationClassSix::RunError(TInt /*aError*/)
       
   216 	{
       
   217 	return KErrNone;
       
   218 	}
       
   219 
       
   220 TUid CImplementationClassSix::ImplId()
       
   221 	{
       
   222 	TUid idVal = {0x101F847E};
       
   223 	return (idVal);
       
   224 	}
       
   225 
       
   226 // __________________________________________________________________________
       
   227 // Exported proxy for instantiation method resolution
       
   228 // Define the interface UIDs
       
   229 const TImplementationProxy ImplementationTable[] = 
       
   230 	{
       
   231 		IMPLEMENTATION_PROXY_ENTRY(0x101F847E,	CImplementationClassSix::NewL)
       
   232 	};
       
   233 
       
   234 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
       
   235 	{
       
   236 	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
       
   237 	return ImplementationTable;
       
   238 	}
       
   239