stif/stif_plat/inc/TestEngineClient.inl
changeset 36 813b186005b6
parent 30 86a2e675b80a
child 41 838cdffd57ce
equal deleted inserted replaced
30:86a2e675b80a 36:813b186005b6
     1 /*
       
     2 * Copyright (c) 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 "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: This file contains implementation of TestEngineClient's 
       
    15 * inline functions.
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef TEST_ENGINE_CLIENT_INL
       
    20 #define TEST_ENGINE_CLIENT_INL
       
    21 
       
    22 // CONSTANTS
       
    23 // None
       
    24 
       
    25 // MACROS
       
    26 // None
       
    27 
       
    28 // DATA TYPES
       
    29 // None
       
    30 
       
    31 // FUNCTION PROTOTYPES
       
    32 // None
       
    33 
       
    34 // FORWARD DECLARATIONS
       
    35 // None
       
    36 
       
    37 // CLASS DECLARATION
       
    38 
       
    39 /*
       
    40 -------------------------------------------------------------------------------
       
    41 
       
    42     Class:CFixedFlatArray
       
    43 
       
    44     Method: CFixedFlatArray
       
    45 
       
    46     Description: Default constructor
       
    47 
       
    48     C++ default constructor can NOT contain any code, that
       
    49     might leave.
       
    50 
       
    51     Parameters: None
       
    52 
       
    53     Return Values: None
       
    54 
       
    55     Errors/Exceptions: None
       
    56 
       
    57     Status: Approved
       
    58 
       
    59 -------------------------------------------------------------------------------
       
    60 */
       
    61 template <class T>
       
    62 CFixedFlatArray<T>::CFixedFlatArray() :
       
    63     iArray( NULL ),
       
    64     iBufferPtr(0,0)
       
    65     {
       
    66 
       
    67     }
       
    68 
       
    69 /*
       
    70 -------------------------------------------------------------------------------
       
    71 
       
    72     Class: CFixedFlatArray
       
    73 
       
    74     Method: ConstructL
       
    75 
       
    76     Description: Symbian OS second phase constructor
       
    77 
       
    78     Symbian OS default constructor can leave.
       
    79 
       
    80     Parameters: const TInt aCount: in: Count of contents
       
    81 
       
    82     Return Values: None
       
    83 
       
    84     Errors/Exceptions: Leaves if memory allocation for iArray of iBuffer fails
       
    85 
       
    86     Status: Approved
       
    87 
       
    88 -------------------------------------------------------------------------------
       
    89 */
       
    90 template <class T>
       
    91 void CFixedFlatArray<T>::ConstructL( const TInt aCount )
       
    92     {
       
    93 
       
    94     iCount = aCount;
       
    95     iArray = new (ELeave) T[iCount];
       
    96 
       
    97     const TInt size = iCount * sizeof (T);
       
    98     iBuffer = HBufC8::NewMaxL ( size );
       
    99 
       
   100     iBufferPtr.Set( iBuffer->Des() );
       
   101     iBufferPtr.SetLength( size );
       
   102     iBufferPtr.Set( (TUint8*) iArray, size,size );
       
   103 
       
   104     }
       
   105 
       
   106 /*
       
   107 -------------------------------------------------------------------------------
       
   108 
       
   109     Class: CFixedFlatArray
       
   110 
       
   111     Method: NewL
       
   112 
       
   113     Description: Two-phased constructor.
       
   114 
       
   115     Parameters: None
       
   116 
       
   117     Return Values: CFixedFlatArray<T>: Array of CFixedFlatArray<T> objects
       
   118 
       
   119     Errors/Exceptions: Leaves if ConstructL leaves
       
   120 
       
   121     Status: Approved
       
   122 
       
   123 -------------------------------------------------------------------------------
       
   124 */
       
   125 template <class T>
       
   126 CFixedFlatArray<T>* CFixedFlatArray<T>::NewL(TInt aSize) 
       
   127     {
       
   128     CFixedFlatArray<T>* self = new ( ELeave ) CFixedFlatArray<T>();
       
   129     CleanupStack::PushL( self );
       
   130     self->ConstructL(aSize);
       
   131     CleanupStack::Pop();
       
   132     return self;
       
   133 
       
   134     }
       
   135 
       
   136 /*
       
   137 -------------------------------------------------------------------------------
       
   138 
       
   139     Class: CFixedFlatArray
       
   140 
       
   141     Method: ~CFixedFlatArray
       
   142 
       
   143     Description: Destructor
       
   144 
       
   145     Parameters: None
       
   146 
       
   147     Return Values: None
       
   148 
       
   149     Errors/Exceptions: None
       
   150 
       
   151     Status: Approved
       
   152 
       
   153 -------------------------------------------------------------------------------
       
   154 */    
       
   155 template <class T>
       
   156 CFixedFlatArray<T>::~CFixedFlatArray()
       
   157     {    
       
   158     delete[] iArray;
       
   159     delete iBuffer;
       
   160 
       
   161     }
       
   162 
       
   163 /*
       
   164 -------------------------------------------------------------------------------
       
   165 
       
   166     Class: CFixedFlatArray
       
   167 
       
   168     Method: Des
       
   169 
       
   170     Description: Returns descriptor for array
       
   171 
       
   172     Parameters: None
       
   173 
       
   174     Return Values: TPtr8&: Descriptor for array
       
   175 
       
   176     Errors/Exceptions: None
       
   177 
       
   178     Status: Approved
       
   179 
       
   180 -------------------------------------------------------------------------------
       
   181 */ 
       
   182 template <class T>
       
   183 TPtr8& CFixedFlatArray<T>::Des()
       
   184     {   
       
   185     return iBufferPtr;
       
   186 
       
   187     }
       
   188 
       
   189 /*
       
   190 -------------------------------------------------------------------------------
       
   191 
       
   192     Class: CFixedFlatArray
       
   193 
       
   194     Method: operator[]
       
   195 
       
   196     Description: Returns index operator
       
   197 
       
   198     Parameters: TInt aIndex: in: Index of object to be returned
       
   199 
       
   200     Return Values: T&: Reference to requested object
       
   201 
       
   202     Errors/Exceptions: Panics if aIndex is out of range
       
   203 
       
   204     Status: Approved
       
   205 
       
   206 -------------------------------------------------------------------------------
       
   207 */ 
       
   208 template <class T>
       
   209 T& CFixedFlatArray<T>::operator[] ( TInt aIndex ) const
       
   210     {
       
   211     CheckIndex( aIndex );
       
   212 
       
   213     return iArray[aIndex];
       
   214 
       
   215     }
       
   216 
       
   217 /*
       
   218 -------------------------------------------------------------------------------
       
   219 
       
   220     Class: CFixedFlatArray
       
   221 
       
   222     Method: Count
       
   223 
       
   224     Description: Returns count
       
   225 
       
   226     Parameters: None
       
   227 
       
   228     Return Values: TInt: iCount
       
   229 
       
   230     Errors/Exceptions: None
       
   231 
       
   232     Status: Approved
       
   233 
       
   234 -------------------------------------------------------------------------------
       
   235 */
       
   236 template <class T>
       
   237 TInt CFixedFlatArray<T>::Count() const
       
   238     {
       
   239     return iCount;
       
   240 
       
   241     }
       
   242 
       
   243 /*
       
   244 -------------------------------------------------------------------------------
       
   245 
       
   246     Class: CFixedFlatArray
       
   247 
       
   248     Method: Set
       
   249 
       
   250     Description: Set buffer to array.
       
   251 
       
   252     Parameters: TInt aIndex: in: Index
       
   253                 T& aBuf: in: Buffer
       
   254 
       
   255     Return Values: None
       
   256 
       
   257     Errors/Exceptions: None
       
   258 
       
   259     Status: Approved
       
   260 
       
   261 -------------------------------------------------------------------------------
       
   262 */
       
   263 template <class T>
       
   264 void CFixedFlatArray<T>::Set( TInt aIndex, T& aBuf )
       
   265     {
       
   266     CheckIndex( aIndex );
       
   267 
       
   268     iArray[aIndex] = aBuf;
       
   269 
       
   270     }
       
   271 
       
   272 /*
       
   273 -------------------------------------------------------------------------------
       
   274 
       
   275     Class: CFixedFlatArray
       
   276 
       
   277     Method: CheckIndex
       
   278 
       
   279     Description: Set buffer to array.
       
   280 
       
   281     Parameters: TInt aIndex: in: Index to be checked
       
   282 
       
   283     Return Values: None
       
   284 
       
   285     Errors/Exceptions: Panics if index is incorrect
       
   286 
       
   287     Status: Approved
       
   288 
       
   289 -------------------------------------------------------------------------------
       
   290 */
       
   291 template <class T>
       
   292 void CFixedFlatArray<T>::CheckIndex( TInt aIndex ) const
       
   293     {
       
   294     if ( aIndex < 0 || aIndex >= iCount )
       
   295         {
       
   296         User::Panic( _L( "CFixedFlatArray: Array index out of range" ), KErrArgument );
       
   297         }
       
   298 
       
   299     }
       
   300 
       
   301 #endif      // TEST_ENGINE_CLIENT_INL
       
   302 
       
   303 // End of File