1 /* 2 * Copyright (C) 2022 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 IMS_BASE_H 17 #define IMS_BASE_H 18 #include <map> 19 #include <memory> 20 #include <string> 21 22 #include "event_runner.h" 23 #include "telephony_log_wrapper.h" 24 #include "telephony_types.h" 25 26 namespace OHOS { 27 namespace Telephony { 28 class ImsBase { 29 public: 30 ImsBase() = default; 31 32 virtual ~ImsBase() = default; 33 34 virtual bool Init() = 0; 35 CreateEventLoop(std::string loopName)36 virtual bool CreateEventLoop(std::string loopName) 37 { 38 eventLoop_ = AppExecFwk::EventRunner::Create(loopName); 39 if (eventLoop_ == nullptr) { 40 TELEPHONY_LOGE("Failed to create EventRunner"); 41 return false; 42 } 43 return true; 44 } 45 46 protected: 47 std::shared_ptr<AppExecFwk::EventRunner> eventLoop_ = nullptr; 48 }; 49 } // namespace Telephony 50 } // namespace OHOS 51 #endif // IMS_BASE_H 52