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