ncdengine/debuglogger/obex/inc/staticarrayc.h
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2006 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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __STATIC_ARRAY_C_H__
       
    20 #define __STATIC_ARRAY_C_H__
       
    21 
       
    22 
       
    23 
       
    24 /*! 
       
    25   @class TStaticArrayC
       
    26   
       
    27   @discussion This templated class provides a type, and size, safe method of
       
    28   using static arrays.
       
    29   */
       
    30 template <class T>
       
    31 class TStaticArrayC
       
    32     {
       
    33 public:
       
    34 
       
    35 /*!
       
    36   @function operator[]
       
    37   
       
    38   @discussion Return an element from the array.
       
    39   @param aIndex the index of the element to return
       
    40   @result a reference to the object
       
    41   */
       
    42     inline const T& operator[](TInt aIndex) const;
       
    43 
       
    44     /*!
       
    45       @enum TPanicCode
       
    46   
       
    47       @discussion Panic code
       
    48       @value EIndexOutOfBounds index is out of bounds
       
    49       */
       
    50     enum TPanicCode
       
    51         { 
       
    52         EIndexOutOfBounds = 1 
       
    53         };
       
    54 
       
    55 /*!
       
    56   @function Panic
       
    57   
       
    58   @discussion Generate a panic.
       
    59   @param aPanicCode the reason code for the panic
       
    60   */
       
    61     inline void Panic(TPanicCode aPanicCode) const;
       
    62 
       
    63 public:
       
    64     /*! @var iArray the arrat of elements */
       
    65     const T* iArray;
       
    66 
       
    67     /*! @var iCount the number of elements */
       
    68     TInt iCount;
       
    69 
       
    70     };
       
    71 
       
    72 /*!
       
    73   @function CONSTRUCT_STATIC_ARRAY_C
       
    74   
       
    75   @discussion Initalise a global constant of type TStaticArrayC<>.
       
    76   @param aValue the underlying const array of T
       
    77   */
       
    78 #define CONSTRUCT_STATIC_ARRAY_C(aValue) \
       
    79         {   \
       
    80         aValue,    \
       
    81         sizeof(aValue) / sizeof(*aValue)  \
       
    82         }  \
       
    83 
       
    84 
       
    85 #include "StaticArrayC.inl"
       
    86 
       
    87 #endif //   __STATIC_ARRAY_C_H__