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 #ifndef EVENT_LISTENER_MANAGER_H 17 #define EVENT_LISTENER_MANAGER_H 18 19 #include <cstdint> 20 #include <memory> 21 22 #include "event_listener.h" 23 #include "event_listener_handler.h" 24 #include "telephony_update_event_type.h" 25 26 namespace OHOS { 27 namespace Telephony { 28 class EventListenerManager { 29 public: 30 template<typename T, typename D> 31 inline static bool SendEvent(uint32_t innerEventId, std::unique_ptr<T, D> &object, int64_t delayTime = 0) 32 { 33 return DelayedSingleton<EventListenerHandler>::GetInstance()->SendEvent(innerEventId, object, delayTime); 34 } 35 static std::optional<int32_t> RegisterEventListener(EventListener &eventListener); 36 static std::optional<int32_t> UnregisterEventListener(int32_t slotId, const TelephonyUpdateEventType eventType); 37 static void RemoveListener(TelephonyUpdateEventType eventType); 38 }; 39 } // namespace Telephony 40 } // namespace OHOS 41 #endif // EVENT_LISTENER_MANAGER_H