• 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 PARSE_PLUGIN_CONFIG_H
17 #define PARSE_PLUGIN_CONFIG_H
18 
19 #include <map>
20 #include <string>
21 
22 #include "google/protobuf/text_format.h"
23 #include "profiler_service.grpc.pb.h"
24 
25 class ParsePluginConfig {
26 public:
27     static ParsePluginConfig& GetInstance();
28 
29     std::string GetPluginsConfig(std::string& content);
30     std::string GetPluginsPath(std::string& name);
31     bool SetSerializePluginsConfig(const std::string& pluginName, ProfilerPluginConfig& pluginConfig);
32 
33     bool SetSerializeCpuConfig(const std::string& pluginName, ProfilerPluginConfig& pluginConfig);
34     bool SetSerializeDiskioConfig(const std::string& pluginName, ProfilerPluginConfig& pluginConfig);
35     bool SetSerializeFtraceConfig(const std::string& pluginName, ProfilerPluginConfig& pluginConfig);
36     bool SetSerializeHidumpConfig(const std::string& pluginName, ProfilerPluginConfig& pluginConfig);
37     bool SetSerializeHilogConfig(const std::string& pluginName, ProfilerPluginConfig& pluginConfig);
38     bool SetSerializeMemoryConfig(const std::string& pluginName, ProfilerPluginConfig& pluginConfig);
39     bool SetSerializeHookConfig(const std::string& pluginName, ProfilerPluginConfig& pluginConfig);
40     bool SetSerializeNetworkConfig(const std::string& pluginName, ProfilerPluginConfig& pluginConfig);
41     bool SetSerializeProcessConfig(const std::string& pluginName, ProfilerPluginConfig& pluginConfig);
42     bool SetSerializeHiperfConfig(const std::string& pluginName, ProfilerPluginConfig& pluginConfig);
43     bool SetSerializeHisyseventConfig(const std::string& pluginName, ProfilerPluginConfig& pluginConfig);
44 
GetParser()45     google::protobuf::TextFormat::Parser& GetParser()
46     {
47         return parser_;
48     }
49 
50 private:
51     ParsePluginConfig();
~ParsePluginConfig()52     ~ParsePluginConfig() {}
53 
54     std::map<std::string, std::string> pluginConfigMap;
55     google::protobuf::TextFormat::Parser parser_;
56 };
57 
58 
59 #endif