|
1 /* |
|
2 * Copyright (c) 2004 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: One value adapter for generic array. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 |
|
20 // ================= MEMBER FUNCTIONS ======================= |
|
21 |
|
22 // C++ default constructor can NOT contain any code, that |
|
23 // might leave. |
|
24 template < class T > |
|
25 inline TPEngGenArrayAdapter< T >::TPEngGenArrayAdapter( const T& aValue ) |
|
26 : iValue( aValue ) |
|
27 { |
|
28 } |
|
29 |
|
30 |
|
31 //Destructor |
|
32 template < class T > |
|
33 inline TPEngGenArrayAdapter< T >::~TPEngGenArrayAdapter() |
|
34 { |
|
35 } |
|
36 |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // TPEngGenArrayAdapter::Array() |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 template < class T > |
|
43 inline TArray< T > TPEngGenArrayAdapter< T >::Array() const |
|
44 { |
|
45 return TArray< T >( CountFunction, |
|
46 AtFunction, |
|
47 REINTERPRET_CAST( const CBase*,this) ); |
|
48 } |
|
49 |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // TPEngGenArrayAdapter::CountFunction() |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 template < class T > |
|
56 inline TInt TPEngGenArrayAdapter< T >::CountFunction( const CBase* /*aThis*/ ) |
|
57 { |
|
58 return 1; |
|
59 } |
|
60 |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // TPEngGenArrayAdapter::AtFunction() |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 template < class T > |
|
67 inline const TAny* TPEngGenArrayAdapter< T >::AtFunction( const CBase* aThis, |
|
68 TInt aIndex ) |
|
69 { |
|
70 //there is just one adapted value |
|
71 __ASSERT_ALWAYS( aIndex == 0, User::Panic( _L("GenArrAdpt"), KErrNotFound ) ); |
|
72 |
|
73 const TPEngGenArrayAdapter* self = reinterpret_cast< const TPEngGenArrayAdapter* >( aThis ); |
|
74 return &self->iValue; |
|
75 } |
|
76 |
|
77 |
|
78 // End of File |
|
79 |