• 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 HIVIEW_ADAPTER_DBSTORE_INCLUDE_SOTRE_MANAGER_H
17 #define HIVIEW_ADAPTER_DBSTORE_INCLUDE_SOTRE_MANAGER_H
18 
19 #include <map>
20 #include <memory>
21 #include <mutex>
22 #include <string>
23 
24 #include "doc_store.h"
25 #include "visibility.h"
26 
27 namespace OHOS {
28 namespace HiviewDFX {
29 class Option {
30 public:
31     enum Flag {
32         RDONLY,
33         TRUNC,
34         NO_TRIM_ON_CLOSE
35     };
36 
37     std::string db;
38     Flag flag;
39 };
40 
41 class StoreManager {
42 public:
StoreManager()43     DOCSTORE_API StoreManager() {}
44 
~StoreManager()45     DOCSTORE_API ~StoreManager() {}
46 
47     DOCSTORE_API std::shared_ptr<DocStore> GetDocStore(const Option& option);
48 
49     DOCSTORE_API int OnlineBackupDocStore(const Option& option, const std::string &bakFile);
50 
51     DOCSTORE_API int CloseDocStore(const Option& option);
52 
53     DOCSTORE_API int DeleteDocStore(const Option& option);
54 private:
55     int InnerCloseDocStore(const Option& option);
56     std::mutex mutex_;
57     std::map<std::string, std::shared_ptr<DocStore>> stores_;
58 }; // StoreManager
59 } // HiviewDFX
60 } // OHOS
61 #endif // HIVIEW_ADAPTER_DBSTORE_INCLUDE_SOTRE_MANAGER_H