|
1 /** @file |
|
2 * Copyright (c) 2005-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: Declares ContentDirectory class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef UPNPMAP_H |
|
21 #define UPNPMAP_H |
|
22 |
|
23 |
|
24 #include <e32std.h> |
|
25 #include "upnpmapelement.h" |
|
26 #include "upnpmapbase.h" |
|
27 |
|
28 |
|
29 // FORWARD DECLARATIONS |
|
30 |
|
31 /** |
|
32 * Implementation of simple map |
|
33 * |
|
34 * @lib ContentDirectory |
|
35 * @since Series 60 2.6 |
|
36 */ |
|
37 template<class T> |
|
38 class CUpnpMap : public CUpnpMapBase |
|
39 { |
|
40 public: |
|
41 /** |
|
42 * Two-phased constructor. |
|
43 */ |
|
44 |
|
45 /** |
|
46 * Destructor. |
|
47 */ |
|
48 virtual ~CUpnpMap(); |
|
49 |
|
50 /** |
|
51 * Adds the whole element to the given TXmlEngElement. |
|
52 * @param aElement a element to which the value will be attached |
|
53 * @since Series S60 3.0 |
|
54 */ |
|
55 void PutL(const TDesC8& aKey, T* aValue); |
|
56 const T* Get(const TDesC8& aKey); |
|
57 T* Remove(const TDesC8& aKey); |
|
58 |
|
59 void Clear(); |
|
60 |
|
61 public: |
|
62 /** |
|
63 * C++ default constructor. |
|
64 */ |
|
65 CUpnpMap(); |
|
66 }; |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CUpnpMap::CUpnpMap |
|
70 // C++ default constructor can NOT contain any code, that |
|
71 // might leave. |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 template<class T> |
|
75 CUpnpMap<T>::CUpnpMap() |
|
76 { |
|
77 } |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CUpnpMap::Get |
|
80 // (other items were commented in a header). |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 template<class T> |
|
84 const T* CUpnpMap<T>::Get(const TDesC8& aKey) |
|
85 { |
|
86 return static_cast<T*>( CUpnpMapBase::Get(aKey) ); |
|
87 } |
|
88 // ----------------------------------------------------------------------------- |
|
89 // CUpnpMap::Get |
|
90 // (other items were commented in a header). |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 template<class T> |
|
94 void CUpnpMap<T>::PutL(const TDesC8& aKey, T* aValue) |
|
95 { |
|
96 CUpnpMapBase::PutL(aKey, aValue); |
|
97 } |
|
98 // ----------------------------------------------------------------------------- |
|
99 // CUpnpMap::~CUpnpMap |
|
100 // (other items were commented in a header). |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 template<class T> |
|
104 CUpnpMap<T>::~CUpnpMap() |
|
105 { |
|
106 Clear(); |
|
107 } |
|
108 // ----------------------------------------------------------------------------- |
|
109 // CUpnpMapBase::Clear |
|
110 // (other items were commented in a header). |
|
111 // ----------------------------------------------------------------------------- |
|
112 // |
|
113 template<class T> |
|
114 void CUpnpMap<T>::Clear() |
|
115 { |
|
116 while(iFirst) |
|
117 { |
|
118 CUpnpMapElement* next = iFirst->Next(); |
|
119 delete static_cast<T*>( iFirst->Value() ); |
|
120 delete iFirst; |
|
121 iFirst = next; |
|
122 } |
|
123 } |
|
124 |
|
125 |
|
126 #endif // UPNPMAP_H |