|
1 // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalComponent |
|
19 */ |
|
20 |
|
21 #include "ss_factorycontainermap.h" |
|
22 |
|
23 #include <ss_std.h> |
|
24 #include <comms-infras/ss_log.h> |
|
25 |
|
26 using namespace ESock; |
|
27 using namespace Messages; |
|
28 using namespace Den; |
|
29 using namespace CommsFW; |
|
30 |
|
31 void RPlaneFCMap::Close() |
|
32 { |
|
33 iMap.Close(); |
|
34 } |
|
35 |
|
36 TInt RPlaneFCMap::AddPlaneFC(const Den::TPlayerRole& aPlane, const TNodeId& aFC) |
|
37 { |
|
38 TPlaneFCEntry entry; |
|
39 entry.iPlane = aPlane; |
|
40 entry.iFC = aFC; |
|
41 return iMap.InsertInOrder(entry, TLinearOrder<TPlaneFCEntry>(TPlaneFCEntry::Cmp)); |
|
42 } |
|
43 |
|
44 TNodeId RPlaneFCMap::GetPlaneFC(const Den::TPlayerRole& aPlane) |
|
45 { |
|
46 TNodeId fc; |
|
47 TPlaneFCEntry entry; |
|
48 entry.iPlane = aPlane; |
|
49 TInt idx = iMap.FindInOrder(entry, TLinearOrder<TPlaneFCEntry>(TPlaneFCEntry::Cmp)); |
|
50 if(idx >= 0) |
|
51 { |
|
52 fc = iMap[idx].iFC; |
|
53 } |
|
54 else |
|
55 { |
|
56 LOG(ESockLog::Printf(KESockBootingTag,_L8("RPlaneFCMap::GetPlaneFC(plane %x, kindex %d) no FC found"), aPlane.Role(), aPlane.Kindex())); |
|
57 } |
|
58 return fc; |
|
59 } |
|
60 |
|
61 void RPlaneFCMap::DropFCOfPeer(const Den::TPlayerRole& aPlane, TWorkerId aPeerWorker) |
|
62 { |
|
63 for(int i = iMap.Count() - 1; i >= 0; --i) |
|
64 { |
|
65 const TPlaneFCEntry& entry(iMap[i]); |
|
66 if(aPlane.HasRole(entry.iPlane.Role()) && entry.iFC.Thread() == aPeerWorker) |
|
67 { |
|
68 iMap.Remove(i); |
|
69 } |
|
70 } |
|
71 } |
|
72 |
|
73 TInt RPlaneFCMap::TPlaneFCEntry::Cmp(const TPlaneFCEntry& aLHS, const TPlaneFCEntry& aRHS) |
|
74 { |
|
75 TInt diff = aLHS.iPlane.Role() - aRHS.iPlane.Role(); |
|
76 if(diff == 0) |
|
77 { |
|
78 diff = aLHS.iPlane.Kindex() - aRHS.iPlane.Kindex(); |
|
79 } |
|
80 return diff; |
|
81 } |
|
82 |