|
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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __MDEITEM_H__ |
|
20 #define __MDEITEM_H__ |
|
21 |
|
22 |
|
23 #include <e32base.h> |
|
24 |
|
25 #include <mdccommon.h> |
|
26 |
|
27 /** |
|
28 * Internal identifier for metadata engine database items. Must always be |
|
29 * different from 0. |
|
30 */ |
|
31 class CMdESession; |
|
32 |
|
33 /** |
|
34 * Abstract base class for all items stored in the metadata engine database. |
|
35 */ |
|
36 NONSHARABLE_CLASS(CMdEItem) : public CBase |
|
37 { |
|
38 public: |
|
39 |
|
40 /** |
|
41 * Destructor. |
|
42 */ |
|
43 virtual ~CMdEItem(); |
|
44 |
|
45 |
|
46 /* Methods. */ |
|
47 |
|
48 /** |
|
49 * Returns whether the item belongs to a session. |
|
50 * |
|
51 * @return <code>ETrue</code>, if the item belongs to a session; |
|
52 * <code>EFalse</code>, otherwise |
|
53 */ |
|
54 IMPORT_C TBool BelongsToSession() const; |
|
55 |
|
56 /** |
|
57 * Returns the session the item belongs to. Panics if |
|
58 * the item does not belong to any session. |
|
59 * |
|
60 * @return session that the item belongs to |
|
61 */ |
|
62 IMPORT_C CMdESession& Session() const; |
|
63 |
|
64 /** |
|
65 * Returns whether the item is stored in the database. |
|
66 * |
|
67 * @return <code>ETrue</code>, if the item is in the database; |
|
68 * <code>EFalse</code>, otherwise |
|
69 */ |
|
70 IMPORT_C TBool InDatabase() const; |
|
71 |
|
72 /** |
|
73 * Returns the internal database identifier of the item. |
|
74 * |
|
75 * @return internal database identifier or <code>KNoId</code> if item is not stored in database. |
|
76 */ |
|
77 IMPORT_C TItemId Id() const; |
|
78 |
|
79 /** |
|
80 * Sets that the internal database identifier of the object. |
|
81 * |
|
82 * @param aId internal database identifier |
|
83 */ |
|
84 void SetId(TItemId aId); |
|
85 |
|
86 /** |
|
87 * Sets the session the item belongs to. |
|
88 * |
|
89 * @param aSession session |
|
90 */ |
|
91 void SetSession(CMdESession& aSession); |
|
92 |
|
93 protected: |
|
94 |
|
95 /* Constructors and destructor. */ |
|
96 |
|
97 /** |
|
98 * Constructor. Note that if the new item is in the database |
|
99 * (i.e., it has an internal database identifier), it must also belong |
|
100 * to a session. |
|
101 * |
|
102 * @param aSession session that the new item belongs to; |
|
103 * or 0, if the new item does not belong to any session |
|
104 * @param aId internal database identifier of the new item, |
|
105 * if the item is in the database (note that then also |
|
106 * <code>aSession</code> must be different from 0); |
|
107 * or 0, if the item is not in the database |
|
108 */ |
|
109 CMdEItem(CMdESession* aSession, TItemId aId); |
|
110 |
|
111 /** |
|
112 * Second-phase constructor. |
|
113 */ |
|
114 void ItemBaseConstruct(); |
|
115 |
|
116 /* Utility methods. */ |
|
117 |
|
118 /** |
|
119 * Panics if the item does not belong to any session. |
|
120 */ |
|
121 void CheckSession() const; |
|
122 |
|
123 |
|
124 private: |
|
125 |
|
126 /** Session. */ |
|
127 CMdESession* iSession; |
|
128 |
|
129 /** Internal database identifier. */ |
|
130 TItemId iId; |
|
131 |
|
132 friend class CMdESession; |
|
133 }; |
|
134 |
|
135 #endif // __MDEITEM_H__ |