applayerprotocols/httpexamples/nwsswsptrhnd/CNwssTransLookUpTable.h
changeset 0 b16258d2340f
equal deleted inserted replaced
-1:000000000000 0:b16258d2340f
       
     1 // Copyright (c) 2002-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 //
       
    15 
       
    16 /**
       
    17  @file CNwssTransLookUpTable.h
       
    18  @warning : This file contains Rose Model ID comments - please do not delete
       
    19 */
       
    20 
       
    21 #ifndef	__CNWSSTRANSLOOKUPTABLE_H__
       
    22 #define __CNWSSTRANSLOOKUPTABLE_H__
       
    23 
       
    24 // System includes
       
    25 #include <e32base.h>
       
    26 #include <wapcli.h>
       
    27 
       
    28 
       
    29 // Forward declarations
       
    30 class MWspCOMethodCallback;
       
    31 class MHTTPDataSupplier;
       
    32 class CNwssWspTrHndDataSupplier;
       
    33 
       
    34 
       
    35 /**
       
    36 	@since			7.0
       
    37 	This class implements a simple, pre-allocated look-up table that is used in
       
    38 	the WSP Transport Handler to associate the transaction-related items stored in
       
    39 	instances of the embedded class CNwssTransLUTEntry.
       
    40  */
       
    41 
       
    42 //##ModelId=3BBD8D0600BB
       
    43 class CNwssTransLookUpTable : public CBase
       
    44 	{
       
    45 public: // embedded classes
       
    46 
       
    47 	/**
       
    48 		@since			7.0
       
    49 		This class implements a single entry in the transaction look-up table.  It is
       
    50 		an association of the following five items :
       
    51 		* NWSS Wap Stack transaction handler (RWSPCOTrans)
       
    52 		* NWSS Wap Stack transaction ID (RWSPCOTrans::TTransID) - for convenience
       
    53 		* Client transaction callback (MWspCOMethodCallback)
       
    54 		* Client's request body data supplier (MHTTPDataSupplier)
       
    55 		* WSP Transport Handler response body handler (CNwssWspTrHndDataSupplier)
       
    56 	 */
       
    57 	//##ModelId=3BBD8D150198
       
    58 	class CNwssTransLUTEntry : public CBase
       
    59 		{
       
    60 	public: // methods
       
    61 
       
    62 	/**
       
    63 		Factory construction.
       
    64 		@since			7.0
       
    65 	*/
       
    66 		static CNwssTransLUTEntry* NewL();
       
    67 
       
    68 	/** 
       
    69 		Destructor.
       
    70 		@since			7.0
       
    71 	*/
       
    72 		virtual ~CNwssTransLUTEntry();
       
    73 
       
    74 	private: // methods
       
    75 
       
    76 	/** 
       
    77 		Default constructor.
       
    78 		@since			7.0
       
    79 	*/
       
    80 		//##ModelId=3C4C49C30046
       
    81 		CNwssTransLUTEntry();
       
    82 
       
    83 	public: // attributes
       
    84 
       
    85 		/** Client callback pointer for the transaction. This uniquely identifies the
       
    86 			transaction.
       
    87 		*/
       
    88 		//##ModelId=3C4C49C3003C
       
    89 		MWspCOMethodCallback* iCallback;
       
    90 
       
    91 		/** WAP Stack transaction handle
       
    92 		*/
       
    93 		//##ModelId=3C4C49C30014
       
    94 		RWSPCOTrans iStackTrans;
       
    95 
       
    96 		/** WAP Stack transaction ID
       
    97 		*/
       
    98 		//##ModelId=3C4C49C30002
       
    99 		RWSPCOTrans::TTransID iStackTransID;
       
   100 
       
   101 		/** Response body data handler
       
   102 		*/
       
   103 		//##ModelId=3C4C49C203DE
       
   104 		CNwssWspTrHndDataSupplier* iResponseBodyHandler;
       
   105 
       
   106 		/** A flag to indicate whether this transaction has been aborted by the 
       
   107 			client, but is in the EDone state.
       
   108 		*/
       
   109 		TBool iAborted;
       
   110 		};
       
   111 
       
   112 public: // methods
       
   113 
       
   114 /** 
       
   115 	Factory construction.  Pre-allocates a table of the specified size.
       
   116 	@since			7.0
       
   117 	@param			aTableSize	(in) The initial size of the look-up table.
       
   118 	@return			The newly constructed instance.
       
   119 	@leave			System error codes, e.g. KErrNoMemory.
       
   120  */
       
   121 	//##ModelId=3C4C49D601AC
       
   122 	static CNwssTransLookUpTable* NewL(TInt aTableSize);
       
   123 
       
   124 /**
       
   125 	Destructor.
       
   126 	@since			7.0
       
   127  */
       
   128 	//##ModelId=3C4C49D6015C
       
   129 	virtual ~CNwssTransLookUpTable();
       
   130 
       
   131 /** 
       
   132 	Returns the next available LUT entry at the top of the table.
       
   133 	@since			7.0
       
   134 	@return			A reference to the entry.
       
   135  */
       
   136 	//##ModelId=3C4C49D60101
       
   137 	CNwssTransLUTEntry& NewEntry();
       
   138 
       
   139 /**
       
   140 	Locate a look-up table entry that matches the supplied transaction
       
   141 					ID.  It is assumed that the look-up table user does not allow
       
   142 					duplicates to be entered in the table.
       
   143 	@since			7.0
       
   144 	@param			aTransId	(in)  The WAP Stack transaction ID.
       
   145 	@param			aFound		(out) A flag indicating if the entry was found.
       
   146 	@return			A reference to the located entry.  Note, if aFound is EFalse
       
   147 					the reference should be discard, as it will be garbage.
       
   148  */
       
   149 	//##ModelId=3C4C49D50345
       
   150 	CNwssTransLUTEntry& LookUpByTransId(RWSPCOTrans::TTransID aTransId, TBool& aFound);
       
   151 
       
   152 /**
       
   153 	Locate a look-up table entry that matches the supplied client
       
   154 					method callback.  It is a requirement on the client that it
       
   155 					uses unique MWspCOMethodCallback objects for each transaction.
       
   156 					Hence there is an assumption that the look-up table user does
       
   157 					not allow entries with duplicate callback's to be entered in
       
   158 					the table.
       
   159 	@since			7.0
       
   160 	@param			aCallback	(in)  The client transaction callback.
       
   161 	@param			aFound		(out) A flag indicating if the entry was found.
       
   162 	@return			A reference to the located entry.  Note, if aFound is EFalse
       
   163 					the reference should be discard, as it will be garbage.
       
   164  */
       
   165 	//##ModelId=3C4C49D501AA
       
   166 	CNwssTransLUTEntry& LookUpByCallback(MWspCOMethodCallback& aCallback, TBool& aFound);
       
   167 
       
   168 /**
       
   169 	Removes the entry corresponding to aCallback from the table. Note
       
   170 					that since the table is pre-allocated, the actual entry is just
       
   171 					recycled by moving it to the top of the table, adjusting the high-
       
   172 					water mark (if necessary) to point at it.
       
   173 	@since			7.0
       
   174 	@param			aCallback	(in) A callback, uniquely identifying the table entry
       
   175 									 to remove.
       
   176  */
       
   177 	//##ModelId=3C4C49D500B0
       
   178 	void RemoveEntry(MWspCOMethodCallback& aCallback);
       
   179 
       
   180 /** 
       
   181   		Resizes the look-up table.  If aNewSize exceeds the current
       
   182 					size, then entries are added.  If it is less than the current
       
   183 					size, then surplus entries are deleted.
       
   184   	@since			7.0
       
   185 	@param			aNewSize	(in) The new table size
       
   186 	@leave			System error codes, e.g. KErrNoMemory if the table can't be
       
   187 					enlarged.
       
   188  */
       
   189 	//##ModelId=3C591A9A038E
       
   190 	void ResizeTableL(TInt aNewSize);
       
   191 
       
   192 /**
       
   193 	Indicates whether there are any 'live' entries in the lookup table,
       
   194 	@since			7.0
       
   195 */
       
   196 	//##ModelId=3C9B095601B8
       
   197 	TBool IsEmpty() const;
       
   198 
       
   199 /**
       
   200 	Returns the first entry in the lookup table.
       
   201 	@param			aFound		(out) A flag indicating if the entry was found.
       
   202 	@return			A reference to the located entry.  Note, if aFound is EFalse
       
   203 					the reference should be discard, as it will be garbage.
       
   204 */	
       
   205 	//##ModelId=3C9B09560186
       
   206 	CNwssTransLUTEntry& Head(TBool& aFound);
       
   207 
       
   208 private: // methods
       
   209 
       
   210 /**
       
   211 	Normal constructor.
       
   212 	@since			7.0
       
   213  */
       
   214 	//##ModelId=3C4C49D5004C
       
   215 	CNwssTransLookUpTable();
       
   216 
       
   217 /**
       
   218 	Second phase construction.  Pre-allocates table entries upto
       
   219 					the specified table size.
       
   220 	@since			7.0
       
   221 	@param			aTableSize	(in) The required initial table size.
       
   222 	@leave			System error codes, e.g. KErrNoMemory.
       
   223  */
       
   224 	//##ModelId=3C4C49D40325
       
   225 	void ConstructL(TInt aTableSize);
       
   226   
       
   227 /**
       
   228 	Helper in making look-ups based on a call-back object.
       
   229 	@since			7.0
       
   230 	@param			aCallback	(in) A callback, uniquely identifying a table entry
       
   231 	@param			aIndex		(out) The index in the table at which the entry was located
       
   232 	@return			Pointer to the table entry if found, or NULL if not found.
       
   233  */
       
   234 	//##ModelId=3C9B0956012B
       
   235 	CNwssTransLUTEntry* LookUp(MWspCOMethodCallback& aCallback, TInt& aIndex);
       
   236 
       
   237 private: // attributes
       
   238 
       
   239 	/** The number of active entries in the look-up table.
       
   240 		iEntries[iNumActiveLUTEntries] will return the next free entry.
       
   241 	*/
       
   242 	//##ModelId=3C4DA52D0338
       
   243 	TInt iNumActiveLUTEntries;
       
   244 
       
   245 	/** The pre-allocated look-up table.  It is ready populated with
       
   246 		entry structures.
       
   247 	*/
       
   248 	//##ModelId=3C4C49D402AD
       
   249 	RPointerArray<CNwssTransLUTEntry> iEntries;
       
   250 	};
       
   251 
       
   252 
       
   253 #endif // __CNWSSTRANSLOOKUPTABLE_H__