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 #include "common_event_support_mapper.h" 17 #include "common_event_support.h" 18 #include "event_log_wrapper.h" 19 20 namespace OHOS { 21 namespace EventFwk { CommonEventSupportMapper()22CommonEventSupportMapper::CommonEventSupportMapper() 23 { 24 Init(); 25 } 26 Init()27void CommonEventSupportMapper::Init() 28 { 29 EVENT_LOGI("enter"); 30 31 map_.insert(std::make_pair( 32 CommonEventSupport::COMMON_EVENT_TEST_ACTION1, CommonEventSupport::COMMON_EVENT_TEST_ACTION2)); 33 map_.insert(std::make_pair( 34 CommonEventSupport::COMMON_EVENT_TEST_ACTION2, CommonEventSupport::COMMON_EVENT_TEST_ACTION1)); 35 } 36 GetMappedSupport(const std::string & support,std::string & mappedSupport)37bool CommonEventSupportMapper::GetMappedSupport(const std::string &support, std::string &mappedSupport) 38 { 39 EVENT_LOGI("enter"); 40 41 auto iter = map_.begin(); 42 for (; iter != map_.end(); ++iter) { 43 if (support == iter->first) { 44 mappedSupport = iter->second; 45 break; 46 } 47 } 48 49 if (iter == map_.end()) { 50 return false; 51 } 52 53 return true; 54 } 55 } // namespace EventFwk 56 } // namespace OHOS