|
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 the License "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 * Inline method definitions of class TFavouritesMsg. |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #ifndef FAVOURITES_MSG_INL |
|
22 #define FAVOURITES_MSG_INL |
|
23 |
|
24 // CONSTANTS |
|
25 |
|
26 // Note: a handle / message is always positive. This way, an integer value can |
|
27 // be return both a handle or an error: if it's positive, it's a handle. If it |
|
28 // is negative, it is an error. |
|
29 |
|
30 LOCAL_D const TInt KFuncBits = 8; ///< Function bits. |
|
31 LOCAL_D const TInt KIndexBits = 8; ///< Index bits. |
|
32 LOCAL_D const TInt KChkNumBits = 15; ///< Check number bits. |
|
33 |
|
34 // ================= MEMBER FUNCTIONS ======================= |
|
35 |
|
36 // --------------------------------------------------------- |
|
37 // TFavouritesHandle::TFavouritesHandle() |
|
38 // --------------------------------------------------------- |
|
39 // |
|
40 TFavouritesHandle::TFavouritesHandle( TInt aIndex, TInt aChkNum ) : |
|
41 iData(((aChkNum << KIndexBits) | aIndex) << KFuncBits) |
|
42 { |
|
43 __ASSERT_DEBUG( aIndex < (1 << KIndexBits), \ |
|
44 FavouritesPanic( EFavouritesInternal ) ); |
|
45 __ASSERT_DEBUG( aChkNum < (1 << KChkNumBits), \ |
|
46 FavouritesPanic( EFavouritesInternal ) ); |
|
47 } |
|
48 |
|
49 // --------------------------------------------------------- |
|
50 // TFavouritesHandle::TFavouritesHandle() |
|
51 // --------------------------------------------------------- |
|
52 // |
|
53 TFavouritesHandle::TFavouritesHandle( TInt aHandle ) : |
|
54 iData(aHandle) |
|
55 { |
|
56 __ASSERT_DEBUG( (aHandle & ((1 << KFuncBits) - 1)) == 0, \ |
|
57 FavouritesPanic( EFavouritesInternal ) ); |
|
58 } |
|
59 |
|
60 // --------------------------------------------------------- |
|
61 // TFavouritesHandle::operator TInt() |
|
62 // --------------------------------------------------------- |
|
63 // |
|
64 TFavouritesHandle::operator TInt() const |
|
65 { |
|
66 return iData & (((1 << (KChkNumBits + KIndexBits)) - 1) << KFuncBits ); |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------- |
|
70 // TFavouritesHandle::Index() |
|
71 // --------------------------------------------------------- |
|
72 // |
|
73 TInt TFavouritesHandle::Index() const |
|
74 { |
|
75 return (iData >> KFuncBits) & ((1 << KIndexBits) - 1); |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------- |
|
79 // TFavouritesHandle::ChkNum() |
|
80 // --------------------------------------------------------- |
|
81 // |
|
82 TInt TFavouritesHandle::ChkNum() const |
|
83 { |
|
84 return ((iData >> (KIndexBits + KFuncBits))) & ((1 << KChkNumBits) - 1); |
|
85 } |
|
86 |
|
87 // --------------------------------------------------------- |
|
88 // TFavouritesHandle::IsNull() |
|
89 // --------------------------------------------------------- |
|
90 // |
|
91 TBool TFavouritesHandle::IsNull() const |
|
92 { |
|
93 return !((iData >> KFuncBits) & ((1 << (KChkNumBits + KIndexBits)) - 1 )); |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------- |
|
97 // TFavouritesMsg::TFavouritesMsg() |
|
98 // --------------------------------------------------------- |
|
99 // |
|
100 TFavouritesMsg::TFavouritesMsg( TInt aHandle, TInt aFunction ) |
|
101 : TFavouritesHandle( aHandle ) |
|
102 { |
|
103 __ASSERT_DEBUG( aFunction < EFavengMaxFunction, \ |
|
104 FavouritesPanic( EFavouritesInternal ) ); |
|
105 __ASSERT_DEBUG( aFunction < (1 << KFuncBits), \ |
|
106 FavouritesPanic( EFavouritesInternal ) ); |
|
107 iData |= aFunction; |
|
108 } |
|
109 |
|
110 // --------------------------------------------------------- |
|
111 // TFavouritesMsg::TFavouritesMsg() |
|
112 // --------------------------------------------------------- |
|
113 // |
|
114 TFavouritesMsg::TFavouritesMsg( TInt aMsg ): TFavouritesHandle( 0 ) |
|
115 { |
|
116 __ASSERT_DEBUG( (aMsg & ((1 << KFuncBits) - 1)) < EFavengMaxFunction, \ |
|
117 FavouritesPanic( EFavouritesInternal ) ); |
|
118 iData = aMsg; |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------- |
|
122 // TFavouritesMsg::operator TInt() |
|
123 // --------------------------------------------------------- |
|
124 // |
|
125 TFavouritesMsg::operator TInt() const |
|
126 { |
|
127 return iData; |
|
128 } |
|
129 |
|
130 // --------------------------------------------------------- |
|
131 // TFavouritesMsg::Function() |
|
132 // --------------------------------------------------------- |
|
133 // |
|
134 TFavouritesFunction TFavouritesMsg::Function() const |
|
135 { |
|
136 return STATIC_CAST \ |
|
137 ( TFavouritesFunction, (iData & ((1 << KFuncBits) - 1 )) ); |
|
138 } |
|
139 |
|
140 #endif |
|
141 |
|
142 // End of File |