Merge "remove badge dependency for legacy NotificationManager" into tizen_2.2
[platform/framework/native/appfw.git] / src / app / FApp_AppRegistryImpl.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 /**
18  * @file        FApp_AppRegistryImpl.h
19  * @brief       This is the header file of the _AppRegistryImpl class.
20  */
21
22 #ifndef _FAPP_INTERNAL_APP_REGISTRY_IMPL_H_
23 #define _FAPP_INTERNAL_APP_REGISTRY_IMPL_H_
24
25 #include <FBaseObject.h>
26 #include <FAppTypes.h>
27 #include <FBaseRtMutex.h>
28
29 namespace Tizen { namespace Io { class Registry; } }
30
31 namespace Tizen { namespace App
32 {
33
34 struct ReadOnlyTag {};
35 struct ReadWriteTag {};
36
37 /**
38  * @class               _AppRegistryImpl
39  * @brief               This class manages an application's preferences.
40  */
41 class _AppRegistryImpl
42 {
43 public:
44         /**
45          * This is the destructor for this class.
46          */
47         ~_AppRegistryImpl(void);
48
49         /**
50          * Adds a string value along with the specified key.
51          *
52          * @return      An error code
53          * @param[in]   key             A key corresponding to the value
54          * @param[in]   value   A string value
55          * @exception   E_SUCCESS                               The method is successful.
56          * @exception   E_INVALID_ARG                   The length of the specified string for a section or entry is smaller than or equal to zero. Or, a @c null value or string with '\0' and '\n' was passed.
57          * @exception   E_KEY_ALREADY_EXIST             The key has already been used in the application preferences.
58          * @exception   E_OUT_OF_MEMORY                 Insufficient memory.
59          * @remark      In order to save the value in the persistent storage, the _AppRegistryImpl::Save() method must be called.
60          */
61         result Add(const Tizen::Base::String& key, const Tizen::Base::String& value);
62
63         /**
64          * Adds an integer value along with the specified key.
65          *
66          * @return      An error code
67          * @param[in]   key             A key corresponding to the value
68          * @param[in]   value   An integer value
69          * @exception   E_SUCCESS                               The method is successful.
70          * @exception   E_INVALID_ARG                   The length of the specified string for a section or entry is smaller than or equal to zero. Or, a @c null value or string with '\0' and '\n' was passed.
71          * @exception   E_KEY_ALREADY_EXIST             The key has already been used in the application preferences.
72          * @exception   E_OUT_OF_MEMORY                 Insufficient memory.
73          * @remark      Call the _AppRegistryImpl::Save() method to save the value in the persistent storage.
74          */
75         result Add(const Tizen::Base::String& key, int value);
76
77         /**
78          * Adds a floating point value along with the specified key.
79          *
80          * @return      An error code
81          * @param[in]   key             A key corresponding to the value
82          * @param[in]   value   A floating point value
83          * @exception   E_SUCCESS                               The method is successful.
84          * @exception   E_INVALID_ARG                   The length of the specified string for a section or entry is smaller than or equal to zero. Or, a @c null value or string with '\0' and '\n' was passed.
85          * @exception   E_KEY_ALREADY_EXIST             The key has already been used in the application preferences.
86          * @exception   E_OUT_OF_MEMORY                 Insufficient memory.
87          * @remark      Call the _AppRegistryImpl::Save() method to save the value in the persistent storage.
88          */
89         result Add(const Tizen::Base::String& key, double value);
90
91         /**
92          * Updates a string value associated with the specified key.
93          *
94          * @return      An error code
95          * @param[in]   key             A key corresponding to the value
96          * @param[in]   value   A string value
97          * @exception   E_SUCCESS                       The method is successful.
98          * @exception   E_INVALID_ARG           The length of the specified string for a section or entry is smaller than or equal to zero. Or, a @c null value or string with '\0' and '\n' was passed.
99          * @exception   E_KEY_NOT_FOUND         The specified key was not used in the application preferences.
100          * @exception   E_OUT_OF_MEMORY         Insufficient memory.
101          * @remark      Call the _AppRegistryImpl::Save() method to save the value in the persistent storage.
102          */
103         result Set(const Tizen::Base::String& key, const Tizen::Base::String& value);
104
105         /**
106          * Updates an integer value associated with the specified key.
107          *
108          * @return      An error code
109          * @param[in]   key     A key corresponding to the value
110          * @param[in]   value   An integer value
111          * @exception   E_SUCCESS                       The method is successful.
112          * @exception   E_INVALID_ARG           The length of the specified string for a section or entry is smaller than or equal to zero. Or, a @c null value or string with '\0' and '\n' was passed.
113          * @exception   E_KEY_NOT_FOUND         The specified key was not used in the application preferences.
114          * @exception   E_OUT_OF_MEMORY         Insufficient memory.
115          * @remark      Call the _AppRegistryImpl::Save() method to save the value in the persistent storage.
116          */
117         result Set(const Tizen::Base::String& key, int value);
118
119         /**
120          * Updates a floating point value associated with the specified key.
121          *
122          * @return      An error code
123          * @param[in]   key     A key corresponding to the value
124          * @param[in]   value   A floating point value
125          * @exception   E_SUCCESS                       The method is successful.
126          * @exception   E_INVALID_ARG           The length of the specified string for a section or entry is smaller than or equal to zero. Or, a @c null value or string with '\0' and '\n' was passed.
127          * @exception   E_KEY_NOT_FOUND         The specified key was not used in the application preferences.
128          * @exception   E_OUT_OF_MEMORY         Insufficient memory.
129          * @remark      Call the _AppRegistryImpl::Save() method to save the value in the persistent storage.
130          */
131         result Set(const Tizen::Base::String& key, double value);
132
133         /**
134          * Saves the values temporarily in the persistent storage. @n
135          * This method is invoked internally when the instance of this class is deleted.
136          *
137          * @return      An error code
138          * @exception   E_SUCCESS                       The method is successful.
139          */
140         result Save(void);
141
142         /**
143          * Removes a preference associated with the specified key.
144          *
145          * @return      An error code
146          * @param[in]   key             The key of the value to be removed
147          * @exception   E_SUCCESS                               The method is successful.
148          * @exception   E_KEY_NOT_FOUND         The specified key was not used in the application preferences.
149          */
150         result Remove(const Tizen::Base::String& key);
151
152         /**
153          * Retrieves a string value associated with the specified key.
154          *
155          * @return      An error code
156          * @param[in]   key             The key of the value to retrieve
157          * @param[out]  value   A string value to be retrieved
158          * @exception   E_SUCCESS                       The method is successful.
159          * @exception   E_INVALID_ARG           The length of the specified string for a section or entry is smaller than or equal to zero. Or, a @c null value or string with '\0' and '\n' was passed.
160          * @exception   E_KEY_NOT_FOUND         The specified key was not used in the application preferences.
161          */
162         result Get(const Tizen::Base::String& key, Tizen::Base::String& value) const;
163
164         /**
165          * Retrieves an integer value associated with the specified key.
166          *
167          * @return      An error code
168          * @param[in]   key             The key of the value to retrieve
169          * @param[out]  value   An integer value to be retrieved
170          * @exception   E_SUCCESS                       The method is successful.
171          * @exception   E_INVALID_ARG           The length of the specified string for a section or entry is smaller than or equal to zero. Or, a @c null value or string with '\0' and '\n' was passed.
172          * @exception   E_KEY_NOT_FOUND         The specified key was not used in the application preferences.
173          */
174         result Get(const Tizen::Base::String& key, int& value) const;
175
176         /**
177          * Retrieves a floating point value associated with the specified key.
178          *
179          * @return      An error code
180          * @param[in]   key             The key of the value to retrieve
181          * @param[out]  value   A floating point value to be retrieved
182          * @exception   E_SUCCESS                       The method is successful.
183          * @exception   E_INVALID_ARG           The length of the specified string for a section or entry is smaller than or equal to zero. Or, a @c null value or string with '\0' and '\n' was passed.
184          * @exception   E_KEY_NOT_FOUND         The specified key was not used in the application preferences.
185          */
186         result Get(const Tizen::Base::String& key, double& value) const;
187
188 private:
189         /**
190          * This is the default constructor for this class.
191          */
192         _AppRegistryImpl(void);
193
194         /**
195          * This is the copy constructor for this class.
196          */
197         _AppRegistryImpl(const _AppRegistryImpl& source);
198
199         /**
200          * Allocates memory for an _AppRegistryImpl object.
201          *
202          * @return      An error code
203          * @exception   E_SUCCESS       The method is successful.
204          */
205         result Construct(void);
206
207         /**
208          * This is the assignment operator for this class.
209          */
210         _AppRegistryImpl& operator =(const _AppRegistryImpl& source);
211
212         /**
213          * Loads the registry file.
214          *
215          * @since               2.2
216          * @return              The registry instance
217          * @exception   E_SUCCESS       The method is successful.
218          */
219         Tizen::Io::Registry* LoadN(ReadOnlyTag) const;
220
221         /**
222          * Loads the registry file.
223          *
224          * @since               2.2
225          * @return              The registry instance
226          * @exception   E_SUCCESS       The method is successful.
227          */
228         Tizen::Io::Registry* LoadN(ReadWriteTag) const;
229
230
231 private:
232         const Tizen::Base::String __sectionName;
233         Tizen::Base::String __regPath;
234         mutable Tizen::Base::Runtime::Mutex __mutex;
235
236         friend class AppRegistry;
237 }; // _AppRegistryImpl
238
239 } } // Tizen::App
240
241 #endif // _FAPP_INTERNAL_APP_REGISTRY_IMPL_H_