1 /* 2 * Copyright (C) 2025 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 GAME_EVENT_H 17 #define GAME_EVENT_H 18 #include "../interface/GameEventCallback.h" 19 #include "sp_profiler.h" 20 #include <string> 21 22 namespace OHOS { 23 namespace SmartPerf { 24 class GameEventCallbackImpl : public GameEventCallback { 25 public: GameEventCallbackImpl()26 GameEventCallbackImpl() {}; 27 void OnGameEvent(int32_t type, std::map<std::string, std::string> ¶ms) override; 28 }; 29 30 class GameEvent : public SpProfiler { 31 public: 32 std::map<std::string, std::string> ItemData() override; GetInstance()33 static GameEvent &GetInstance() 34 { 35 static GameEvent instance; 36 return instance; 37 } 38 int RegisterGameEvent(); 39 int UnregisterGameEvent(); 40 void StartExecutionOnce(bool isPause) override; 41 void FinishtExecutionOnce(bool isPause) override; 42 std::map<std::string, std::string> &GetGameEventItemData(); 43 private: GameEvent()44 GameEvent() {}; 45 GameEvent(const GameEvent &) = delete; 46 GameEvent &operator=(const GameEvent &) = delete; 47 std::map<std::string, std::string> gameEventParams; 48 std::map<std::string, std::string> gameEventItemData; 49 const std::string gameEventParamPid = "pid"; 50 const std::string gameEventParamType = "functionType"; 51 const std::string createPlugin = "onCreatePlugin"; 52 bool isRegister = false; 53 }; 54 } // namespace SmartPerf 55 } // namespace OHOS 56 #endif // GAME_EVENT_H