• 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 #ifndef DB_PROPERTIES_H
16 #define DB_PROPERTIES_H
17 
18 #include <map>
19 #include <string>
20 
21 namespace DistributedDB {
22 class DBProperties {
23 public:
24     DBProperties() = default;
25     virtual ~DBProperties() = default;
26 
27     // Get the string property according the name
28     std::string GetStringProp(const std::string &name, const std::string &defaultValue) const;
29 
30     // Set the string property for the name
31     void SetStringProp(const std::string &name, const std::string &value);
32 
33     // Get the bool property according the name
34     bool GetBoolProp(const std::string &name, bool defaultValue) const;
35 
36     // Set the bool property for the name
37     void SetBoolProp(const std::string &name, bool value);
38 
39     // Get the bool property according the name
40     int GetIntProp(const std::string &name, int defaultValue) const;
41 
42     // Set the integer property for the name
43     void SetIntProp(const std::string &name, int value);
44 
45     // Set all indentifers
46     void SetIdentifier(const std::string &userId, const std::string &appId, const std::string &storeId,
47         int32_t instanceId = 0);
48 
49     static const std::string CREATE_IF_NECESSARY;
50     static const std::string DATABASE_TYPE;
51     static const std::string DATA_DIR;
52     static const std::string USER_ID;
53     static const std::string APP_ID;
54     static const std::string STORE_ID;
55     static const std::string INSTANCE_ID;
56     static const std::string IDENTIFIER_DATA;
57     static const std::string IDENTIFIER_DIR;
58     static const std::string DUAL_TUPLE_IDENTIFIER_DATA;
59     static const std::string SYNC_DUAL_TUPLE_MODE;
60     static const std::string AUTO_LAUNCH_ID;
61 
62 protected:
63 
64     std::map<std::string, std::string> stringProperties_;
65     std::map<std::string, bool> boolProperties_;
66     std::map<std::string, int> intProperties_;
67 };
68 }
69 #endif