• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FOUNDATION_APPEXECFWK_SERVICES_FORMMGR_INCLUDE_FORM_STORAGE_MGR_H
17 #define FOUNDATION_APPEXECFWK_SERVICES_FORMMGR_INCLUDE_FORM_STORAGE_MGR_H
18 
19 #include <map>
20 #include <string>
21 #include <stdint.h>
22 #include <iostream>
23 
24 #include "appexecfwk_errors.h"
25 #include "form_db_info.h"
26 
27 namespace OHOS {
28 namespace AppExecFwk {
29 /**
30  * @class FormStorageMgr
31  * Form data storage.
32  */
33 class FormStorageMgr {
34 public:
35     FormStorageMgr() = default;
36     virtual ~FormStorageMgr() = default;
37     /**
38      * @brief Load all form data from DB to innerFormInfos.
39      * @param innerFormInfos Storage all form data.
40      * @return Returns ERR_OK on success, others on failure.
41      */
42     ErrCode LoadFormData(std::vector<InnerFormInfo> &innerFormInfos) const;
43 
44     /**
45      * @brief Get form data from DB to innerFormInfo with formId.
46      * @param innerFormInfo Storage form data.
47      * @return Returns ERR_OK on success, others on failure.
48      */
49     ErrCode GetStorageFormInfoById(const std::string &formId, InnerFormInfo &innerFormInfo) const;
50 
51     /**
52      * @brief Save or update the form data in DB.
53      * @param innerFormInfo Indicates the InnerFormInfo object to be save.
54      * @return Returns ERR_OK on success, others on failure.
55      */
56     ErrCode SaveStorageFormInfo(const InnerFormInfo &innerFormInfo) const;
57 
58     /**
59      * @brief Modify the form data in DB.
60      * @param innerFormInfo Indicates the InnerFormInfo object to be Modify.
61      * @return Returns ERR_OK on success, others on failure.
62      */
63     ErrCode ModifyStorageFormInfo(const InnerFormInfo &innerFormInfo) const;
64 
65     /**
66      * @brief Delete the form data in DB.
67      * @param formId The form data Id.
68      * @return Returns ERR_OK on success, others on failure.
69      */
70     ErrCode DeleteStorageFormInfo(const std::string &formId) const;
71 };
72 }  // namespace AppExecFwk
73 }  // namespace OHOS
74 
75 #endif // FOUNDATION_APPEXECFWK_SERVICES_FORMMGR_INCLUDE_FORM_STORAGE_MGR_H
76