2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file FApp_AppRegistryImpl.h
19 * @brief This is the header file of the _AppRegistryImpl class.
22 #ifndef _FAPP_INTERNAL_APP_REGISTRY_IMPL_H_
23 #define _FAPP_INTERNAL_APP_REGISTRY_IMPL_H_
25 #include <FBaseObject.h>
26 #include <FOspConfig.h>
27 #include <FAppTypes.h>
29 namespace Tizen { namespace Io { class Registry; } }
31 namespace Tizen { namespace App
35 * @class _AppRegistryImpl
36 * @brief This class manages an application's preferences.
39 class _AppRegistryImpl
40 : public Tizen::Base::Object
44 * This is the destructor for this class.
48 virtual ~_AppRegistryImpl(void);
51 * Adds a string value along with the specified key.
54 * @return An error code
55 * @param[in] key A key corresponding to the value
56 * @param[in] value A string value
57 * @exception E_SUCCESS The method is successful.
58 * @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.
59 * @exception E_KEY_ALREADY_EXIST The key has already been used in the application preferences.
60 * @exception E_OUT_OF_MEMORY Insufficient memory.
61 * @remark In order to save the value in the persistent storage, the _AppRegistryImpl::Save() method must be called.
63 result Add(const Tizen::Base::String& key, const Tizen::Base::String& value);
66 * Adds an integer value along with the specified key.
69 * @return An error code
70 * @param[in] key A key corresponding to the value
71 * @param[in] value An integer value
72 * @exception E_SUCCESS The method is successful.
73 * @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.
74 * @exception E_KEY_ALREADY_EXIST The key has already been used in the application preferences.
75 * @exception E_OUT_OF_MEMORY Insufficient memory.
76 * @remark Call the _AppRegistryImpl::Save() method to save the value in the persistent storage.
78 result Add(const Tizen::Base::String& key, int value);
81 * Adds a floating point value along with the specified key.
84 * @return An error code
85 * @param[in] key A key corresponding to the value
86 * @param[in] value A floating point value
87 * @exception E_SUCCESS The method is successful.
88 * @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.
89 * @exception E_KEY_ALREADY_EXIST The key has already been used in the application preferences.
90 * @exception E_OUT_OF_MEMORY Insufficient memory.
91 * @remark Call the _AppRegistryImpl::Save() method to save the value in the persistent storage.
93 result Add(const Tizen::Base::String& key, double value);
96 * Updates a string value associated with the specified key.
99 * @return An error code
100 * @param[in] key A key corresponding to the value
101 * @param[in] value A string value
102 * @exception E_SUCCESS The method is successful.
103 * @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.
104 * @exception E_KEY_NOT_FOUND The specified key was not used in the application preferences.
105 * @exception E_OUT_OF_MEMORY Insufficient memory.
106 * @remark Call the _AppRegistryImpl::Save() method to save the value in the persistent storage.
108 result Set(const Tizen::Base::String& key, const Tizen::Base::String& value);
111 * Updates an integer value associated with the specified key.
114 * @return An error code
115 * @param[in] key A key corresponding to the value
116 * @param[in] value An integer value
117 * @exception E_SUCCESS The method is successful.
118 * @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.
119 * @exception E_KEY_NOT_FOUND The specified key was not used in the application preferences.
120 * @exception E_OUT_OF_MEMORY Insufficient memory.
121 * @remark Call the _AppRegistryImpl::Save() method to save the value in the persistent storage.
123 result Set(const Tizen::Base::String& key, int value);
126 * Updates a floating point value associated with the specified key.
129 * @return An error code
130 * @param[in] key A key corresponding to the value
131 * @param[in] value A floating point value
132 * @exception E_SUCCESS The method is successful.
133 * @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.
134 * @exception E_KEY_NOT_FOUND The specified key was not used in the application preferences.
135 * @exception E_OUT_OF_MEMORY Insufficient memory.
136 * @remark Call the _AppRegistryImpl::Save() method to save the value in the persistent storage.
138 result Set(const Tizen::Base::String& key, double value);
141 * Saves the values temporarily in the persistent storage. @n
142 * This method is invoked internally when the instance of this class is deleted.
145 * @return An error code
146 * @exception E_SUCCESS The method is successful.
151 * Removes a preference associated with the specified key.
154 * @return An error code
155 * @param[in] key The key of the value to be removed
156 * @exception E_SUCCESS The method is successful.
157 * @exception E_KEY_NOT_FOUND The specified key was not used in the application preferences.
159 result Remove(const Tizen::Base::String& key);
162 * Retrieves a string value associated with the specified key.
165 * @return An error code
166 * @param[in] key The key of the value to retrieve
167 * @param[out] value A string value to be retrieved
168 * @exception E_SUCCESS The method is successful.
169 * @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.
170 * @exception E_KEY_NOT_FOUND The specified key was not used in the application preferences.
172 result Get(const Tizen::Base::String& key, Tizen::Base::String& value) const;
175 * Retrieves an integer value associated with the specified key.
178 * @return An error code
179 * @param[in] key The key of the value to retrieve
180 * @param[out] value An integer value to be retrieved
181 * @exception E_SUCCESS The method is successful.
182 * @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.
183 * @exception E_KEY_NOT_FOUND The specified key was not used in the application preferences.
185 result Get(const Tizen::Base::String& key, int& value) const;
188 * Retrieves a floating point value associated with the specified key.
191 * @return An error code
192 * @param[in] key The key of the value to retrieve
193 * @param[out] value A floating point value to be retrieved
194 * @exception E_SUCCESS The method is successful.
195 * @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.
196 * @exception E_KEY_NOT_FOUND The specified key was not used in the application preferences.
198 result Get(const Tizen::Base::String& key, double& value) const;
202 * This is the default constructor for this class.
206 _AppRegistryImpl(void);
209 * This is the copy constructor for this class.
213 _AppRegistryImpl(const _AppRegistryImpl& source);
216 * Allocates memory for an _AppRegistryImpl object.
219 * @return An error code
220 * @exception E_SUCCESS The method is successful.
222 result Construct(void);
225 * This is the assignment operator for this class.
227 _AppRegistryImpl& operator =(const _AppRegistryImpl& source);
230 * Loads the registry file.
233 * @return An error code
234 * @exception E_SUCCESS The method is successful.
236 result Load(void) const;
239 * Unloads the registry file.
243 void Unload(void) const;
246 mutable Tizen::Io::Registry* __pRegistry;
247 const Tizen::Base::String __sectionName;
248 Tizen::Base::String __regPath;
250 friend class AppRegistry;
251 }; // _AppRegistryImpl
255 #endif // _FAPP_INTERNAL_APP_REGISTRY_IMPL_H_