|
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: Implementation Trigger Key class used to identify trigger |
|
15 * information stored in the BTree |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #include "lbttriggerkey.h" |
|
22 #include "lbtcontainertriggerentry.h" |
|
23 |
|
24 |
|
25 // ======== MEMBER FUNCTIONS ======== |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // TLbtTriggerKey::Between |
|
29 // |
|
30 // ----------------------------------------------------------------------------- |
|
31 // |
|
32 void TLbtTriggerKey::Between( const TAny* aLeft, const TAny* aRight, |
|
33 TBtreePivot& aPivot ) const |
|
34 { |
|
35 TUint32 left = *( TUint32* ) aLeft; |
|
36 TUint32 right = *( TUint32* ) aRight; |
|
37 |
|
38 TUint32 mid = left + ( right - left ) / 2; |
|
39 aPivot.Copy( ( TUint8* ) &mid, sizeof( mid ) ); |
|
40 } |
|
41 |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // TLbtTriggerKey::Compare |
|
45 // |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 TInt TLbtTriggerKey::Compare( const TAny* aLeft, const TAny* aRight ) const |
|
49 { |
|
50 TUint32 left,right; |
|
51 if( aLeft ) |
|
52 { |
|
53 left = *( TUint32* ) aLeft; |
|
54 } |
|
55 else |
|
56 { |
|
57 return -1; |
|
58 } |
|
59 |
|
60 if( aRight ) |
|
61 { |
|
62 right = *( TUint32* ) aRight; |
|
63 } |
|
64 else |
|
65 { |
|
66 return 1; |
|
67 } |
|
68 |
|
69 if( left < right ) |
|
70 { |
|
71 return -1; |
|
72 } |
|
73 else if( left > right ) |
|
74 { |
|
75 return 1; |
|
76 } |
|
77 return 0; |
|
78 } |
|
79 |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // TLbtTriggerKey::Key |
|
83 // |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 const TAny* TLbtTriggerKey::Key( const TAny* anEntry ) const |
|
87 { |
|
88 /* CLbtContainerTriggerEntry* t = (CLbtContainerTriggerEntry* ) anEntry; |
|
89 CLbtTriggerEntry *trigEntry=t->TriggerEntry(); |
|
90 return ( TAny* ) &( trigEntry->Id() );*/ |
|
91 |
|
92 //krishna's fix :) |
|
93 |
|
94 CLbtContainerTriggerEntry** t1 = (CLbtContainerTriggerEntry** ) (anEntry); |
|
95 CLbtContainerTriggerEntry* t=(CLbtContainerTriggerEntry*) *t1; |
|
96 CLbtTriggerEntry *trigEntry=t->TriggerEntry(); |
|
97 return ( TAny* ) &( trigEntry->Id() ); |
|
98 |
|
99 } |