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 25using MesTypeMap = std::map<XpowerMessageType, OptimizeMessageType>; 26 27class XpowerPlugin { 28public: 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); 37private: 38 void* powerClientHandle_ = nullptr; 39 XpowerConfig protoConfig_; 40 MesTypeMap procMesTypeMapping_; 41 std::shared_ptr<PowerMessageQueue> dataQueuePtr_; 42 WriterStruct* resultWriter_{nullptr}; 43 // xpower callback config 44 OptimizeConfig config_{}; 45 void* listenerHandle_ = nullptr; 46}; 47 48#endif // POWER_PLUGIN_H 49