tizen beta release
[framework/web/wrt-plugins-common.git] / src / modules / API / LocalStorage / ILocalStorage.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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  * @author      Grzegorz Krawczyk (g.krawczyk@samsung.com)
18  * @author      Andrzej Surdej (a.surdej@samsung.com)
19  * @version     0.1
20  * @brief       Local storage interface file
21  */
22
23 #ifndef WRTDEVICEAPIS_LOCALSTORAGE_LOCAL_STORAGE_INTERFACE_H_
24 #define WRTDEVICEAPIS_LOCALSTORAGE_LOCAL_STORAGE_INTERFACE_H_
25
26 #include <string>
27 #include <dpl/shared_ptr.h>
28 #include <dpl/optional.h>
29
30 namespace WrtDeviceApis {
31 namespace LocalStorage {
32 namespace Api {
33
34 class ILocalStorage
35 {
36   public:
37
38     /**
39      * Save pair key/value in local storage
40      * @param key
41      * @param value
42      * @param readOnly - if true, the value will be read only
43      *                  otherwise the value will be modificable
44      */
45     virtual void setItem(const std::string& key,
46                          const std::string& value,
47                          bool readOnly) = 0;
48
49     /**
50      * Remove pair key/value from local storage
51      */
52     virtual void removeItem(const std::string& key) = 0;
53
54     /**
55      * Get value for key
56      *
57      */
58     virtual DPL::Optional<std::string> getValue(
59             const std::string& key) const = 0;
60
61     /**
62      * Clears the local storage
63      * @param removeReadOnly - true -remove all elements
64      *                          false - ommit items which have read only flag set
65      */
66     virtual void clear(bool removeReadOnly) = 0;
67
68     /**
69      * Get number of elements in local storage
70      * @param removeReadOnly - true -remove all elements
71      *                          false - ommit items which have read only flag set
72      */
73     virtual size_t getStorageSize() const = 0;
74
75     /**
76      * Get value for key
77      */
78     virtual std::string getValueByIndex(size_t index) const = 0;
79
80     /**
81      * virtual destructor
82      */
83     virtual ~ILocalStorage()
84     {
85     }
86
87 };
88
89 typedef DPL::SharedPtr<ILocalStorage> ILocalStoragePtr;
90
91 } // Api
92 } // LocalStorage
93 } // WrtDeviceApis
94
95 #endif // WRTDEVICEAPIS_LOCALSTORAGE_LOACA_STORAGE_INTERFACE_H_