• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) Huawei Technologies Co., Ltd. 2023. All rights reserved.
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 POWER_PLUGIN_H
17 #define POWER_PLUGIN_H
18 
19 #include "logging.h"
20 #include "plugin_module_api.h"
21 #include "power_message_queue.h"
22 #include "xpower_common.h"
23 #include "xpower_plugin_result.pb.h"
24 
25 using MesTypeMap = std::map<XpowerMessageType, OptimizeMessageType>;
26 
27 class XpowerPlugin {
28 public:
29     XpowerPlugin();
30     ~XpowerPlugin();
31     int Start(const uint8_t* configData, uint32_t configSize);
32     int Report(uint8_t* configData, uint32_t configSize);
33     int Stop();
34     void OptimizeCallback(const std::uint32_t messageType, const uint8_t* protoData, size_t protoSize);
35     void SetWriter(WriterStruct* writer);
36     bool StartPowerManager(std::uint32_t messageType, std::string& bundleName);
37     std::string GetCmdArgs(const XpowerConfig& traceConfig);
38 private:
39     void* powerClientHandle_ = nullptr;
40     XpowerConfig protoConfig_;
41     MesTypeMap procMesTypeMapping_;
42     std::shared_ptr<PowerMessageQueue> dataQueuePtr_;
43     WriterStruct* resultWriter_{nullptr};
44     // xpower callback config
45     OptimizeConfig config_{};
46     void* listenerHandle_ = nullptr;
47 };
48 
49 #endif // POWER_PLUGIN_H
50