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: |
|
15 * |
|
16 */ |
|
17 #include "tsmodelitemkey.h" |
|
18 // ----------------------------------------------------------------------------- |
|
19 /** |
|
20 * @return amount of memory ( number of bytes ) required to store key. |
|
21 */ |
|
22 TInt TTsModelItemKey::Size() |
|
23 { |
|
24 return sizeof( TInt ) * 2; |
|
25 } |
|
26 // ----------------------------------------------------------------------------- |
|
27 /** |
|
28 * Default constructor. Key members are initialized with 0 |
|
29 */ |
|
30 TTsModelItemKey::TTsModelItemKey() |
|
31 : |
|
32 iKey( 0 ), |
|
33 iRoot( 0 ) |
|
34 { |
|
35 //No implementation required |
|
36 } |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 /** |
|
40 * Constructor. Initialize members with provided values. |
|
41 * @param aKey - key value |
|
42 * @param aRoot - root value |
|
43 */ |
|
44 TTsModelItemKey::TTsModelItemKey( TTsKey aKey, TInt aRoot ) |
|
45 : |
|
46 iKey( aKey ), |
|
47 iRoot( aRoot ) |
|
48 { |
|
49 //No implementation required |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 /** |
|
54 * Copy constructor |
|
55 * @param aKey - key value that need to be duplicated |
|
56 */ |
|
57 TTsModelItemKey::TTsModelItemKey( const TTsModelItemKey& aKey ) |
|
58 : |
|
59 iKey( aKey.iKey ), |
|
60 iRoot( aKey.iRoot ) |
|
61 { |
|
62 //No implementation required |
|
63 } |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 /** |
|
67 * Assignment operator. Initialize members with new values |
|
68 * @param aKey - key value that need to be duplicated |
|
69 * @return reference to key instance |
|
70 */ |
|
71 TTsModelItemKey& TTsModelItemKey::operator =( const TTsModelItemKey& aKey ) |
|
72 { |
|
73 iKey = aKey.iKey; |
|
74 iRoot = aKey.iRoot; |
|
75 return (*this); |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 /** |
|
80 * Comparison operator |
|
81 * @param aKey - compared value |
|
82 * @return EFalse if values are not equal, other value if they match |
|
83 */ |
|
84 TBool TTsModelItemKey::operator == ( const TTsModelItemKey aKey ) const |
|
85 { |
|
86 return ( iKey == aKey.iKey && iRoot == aKey.iRoot ); |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 /** |
|
91 * Enable access to key value |
|
92 * @return key value |
|
93 */ |
|
94 TInt TTsModelItemKey::Key() const |
|
95 { |
|
96 return iKey; |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 /** |
|
101 * Serialize key into data stream |
|
102 * @param aStream - destination binary stream |
|
103 */ |
|
104 void TTsModelItemKey::ExternalizeL( RWriteStream& aStream ) const |
|
105 { |
|
106 aStream.WriteInt32L( iKey ); |
|
107 aStream.WriteInt32L( iRoot ); |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 /** |
|
112 * Deserialize key from data stream |
|
113 * @param aStream - source binary stream |
|
114 */ |
|
115 void TTsModelItemKey::InternalizeL( RReadStream& aStream ) |
|
116 { |
|
117 iKey = aStream.ReadInt32L(); |
|
118 iRoot = aStream.ReadInt32L(); |
|
119 } |
|