1 /* 2 * Copyright (c) 2024 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 I_EVENT_BEAN_H 17 #define I_EVENT_BEAN_H 18 19 #include <map> 20 #include "media_monitor_info.h" 21 #include "iremote_proxy.h" 22 #include "parcel.h" 23 24 namespace OHOS { 25 namespace Media { 26 namespace MediaMonitor { 27 28 class EventBean : public Parcelable { 29 public: 30 EventBean(); 31 EventBean(const ModuleId &mId, const EventId &eId, 32 const EventType &type); 33 ~EventBean() = default; 34 35 void Add(const std::string &key, int32_t value); 36 void Add(const std::string &key, std::string value); 37 void Add(const std::string &key, uint64_t value); 38 void Add(const std::string &key, float value); 39 40 std::map<std::string, int32_t> GetIntMap(); 41 std::map<std::string, std::string> GetStringMap(); 42 std::map<std::string, uint64_t> GetUint64Map(); 43 std::map<std::string, float> GetFloatMap(); 44 45 void UpdateIntMap(const std::string &key, int32_t value); 46 void UpdateStringMap(const std::string &key, std::string value); 47 void UpdateUint64Map(const std::string &key, uint64_t value); 48 void UpdateFloatMap(const std::string &key, float value); 49 50 int32_t GetIntValue(const std::string &key); 51 std::string GetStringValue(const std::string &key); 52 uint64_t GetUint64Value(const std::string &key); 53 float GetFloatValue(const std::string &key); 54 55 ModuleId GetModuleId(); 56 EventId GetEventId(); 57 EventType GetEventType(); 58 59 void SetModuleId(const ModuleId &mId); 60 void SetEventId(const EventId &eId); 61 void SetEventType(const EventType &type); 62 63 void ReadFromParcel(MessageParcel &parcel); 64 65 bool Marshalling(Parcel &parcel) const override; 66 static EventBean *Unmarshalling(Parcel &data); 67 68 private: 69 ModuleId moduleId_ = UNKNOW_MODULEID; 70 EventId eventId_ = UNKNOW_EVENTID; 71 EventType eventType_ = UNKNOW_EVENTTYPE; 72 std::map<std::string, int32_t> intMap_; 73 std::map<std::string, std::string> stringMap_; 74 std::map<std::string, uint64_t> uint64Map_; 75 std::map<std::string, float> floatMap_; 76 }; 77 } // namespace MediaMonitor 78 } // namespace Media 79 } // namespace OHOS 80 81 #endif // I_EVENT_BEAN_H