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 <FAppTypes.h>
27 #include <FBaseRtMutex.h>
29 namespace Tizen { namespace Io { class Registry; } }
31 namespace Tizen { namespace App
34 struct ReadOnlyTag {};
35 struct ReadWriteTag {};
38 * @class _AppRegistryImpl
39 * @brief This class manages an application's preferences.
41 class _AppRegistryImpl
45 * This is the destructor for this class.
47 ~_AppRegistryImpl(void);
50 * Adds a string value along with the specified key.
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.
61 result Add(const Tizen::Base::String& key, const Tizen::Base::String& value);
64 * Adds an integer value along with the specified key.
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.
75 result Add(const Tizen::Base::String& key, int value);
78 * Adds a floating point value along with the specified key.
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.
89 result Add(const Tizen::Base::String& key, double value);
92 * Updates a string value associated with the specified key.
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.
103 result Set(const Tizen::Base::String& key, const Tizen::Base::String& value);
106 * Updates an integer value associated with the specified key.
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.
117 result Set(const Tizen::Base::String& key, int value);
120 * Updates a floating point value associated with the specified key.
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.
131 result Set(const Tizen::Base::String& key, double value);
134 * Saves the values temporarily in the persistent storage. @n
135 * This method is invoked internally when the instance of this class is deleted.
137 * @return An error code
138 * @exception E_SUCCESS The method is successful.
143 * Removes a preference associated with the specified key.
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.
150 result Remove(const Tizen::Base::String& key);
153 * Retrieves a string value associated with the specified key.
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.
162 result Get(const Tizen::Base::String& key, Tizen::Base::String& value) const;
165 * Retrieves an integer value associated with the specified key.
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.
174 result Get(const Tizen::Base::String& key, int& value) const;
177 * Retrieves a floating point value associated with the specified key.
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.
186 result Get(const Tizen::Base::String& key, double& value) const;
190 * This is the default constructor for this class.
192 _AppRegistryImpl(void);
195 * This is the copy constructor for this class.
197 _AppRegistryImpl(const _AppRegistryImpl& source);
200 * Allocates memory for an _AppRegistryImpl object.
202 * @return An error code
203 * @exception E_SUCCESS The method is successful.
205 result Construct(void);
208 * This is the assignment operator for this class.
210 _AppRegistryImpl& operator =(const _AppRegistryImpl& source);
213 * Loads the registry file.
216 * @return The registry instance
217 * @exception E_SUCCESS The method is successful.
219 Tizen::Io::Registry* LoadN(ReadOnlyTag) const;
222 * Loads the registry file.
225 * @return The registry instance
226 * @exception E_SUCCESS The method is successful.
228 Tizen::Io::Registry* LoadN(ReadWriteTag) const;
232 const Tizen::Base::String __sectionName;
233 Tizen::Base::String __regPath;
234 mutable Tizen::Base::Runtime::Mutex __mutex;
236 friend class AppRegistry;
237 }; // _AppRegistryImpl
241 #endif // _FAPP_INTERNAL_APP_REGISTRY_IMPL_H_