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