• 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 AW_CXX_DISTRIBUTED_DISTRIBUTED_CFG_H_
17 #define AW_CXX_DISTRIBUTED_DISTRIBUTED_CFG_H_
18 
19 #include <map>
20 #include <iostream>
21 
22 namespace OHOS {
23 namespace DistributeSystemTest {
24 using namespace std;
25 enum AGENT_NO {
26     ZERO = 0,
27     ONE = 1,
28     TWO = 2,
29     THREE = 3,
30     FOUR = 4,
31     FIVE = 5,
32     SIX = 6,
33     SEVEN = 7,
34     EIGHT = 8,
35     NINE = 9
36 };
37 
38 class DistributedCfg {
39 public:
40     DistributedCfg();
41     ~DistributedCfg();
42     bool OpenCfg(std::string fileName);
43     bool GetCfgVal(std::string key, std::string &value);
44     std::string GetValueInString(std::string str, size_t devNo);
45     std::string GetDeviceIp(std::string fileName, size_t devNo);
46     std::string GetDeviceUuid(std::string fileName, size_t devNo);
47     static std::unique_ptr<DistributedCfg>& GetInstance();
48     static std::unique_ptr<DistributedCfg> getCfg_;
49 
50 private:
51     std::map<std::string, std::string> cfgMap_;  // <cfgkey, cfgvalue>  from env.desc file
52 };
53 } // namespace DistributeSystemTest
54 } // namespace OHOS
55 
56 #endif // AW_CXX_DISTRIBUTED_DISTRIBUTED_CFG_H_
57