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 TIMER_INFO_H 17 #define TIMER_INFO_H 18 19 #include "itimer_info.h" 20 21 namespace OHOS { 22 namespace Accessibility { 23 24 class TimerInfo : public OHOS::MiscServices::ITimerInfo { 25 public: 26 TimerInfo(); 27 virtual ~TimerInfo(); 28 void OnTrigger() override; 29 void SetType(const int &type) override; 30 void SetRepeat(bool repeat) override; 31 void SetInterval(const uint64_t &_interval) override; 32 void SetWantAgent(std::shared_ptr<AbilityRuntime::WantAgent::WantAgent> wantAgent) override; 33 void SetCallbackInfo(const std::function<void()> &callBack); 34 void SetTimerId(uint64_t timeId); 35 private: 36 std::function<void()> callBack { nullptr }; 37 }; 38 TimerInfo()39TimerInfo::TimerInfo() 40 { 41 } 42 ~TimerInfo()43TimerInfo::~TimerInfo() 44 { 45 } 46 OnTrigger()47void TimerInfo::OnTrigger() 48 { 49 if (this->callBack != nullptr) { 50 this->callBack(); 51 } 52 } 53 SetCallbackInfo(const std::function<void ()> & callBack)54void TimerInfo::SetCallbackInfo(const std::function<void()> &callBack) 55 { 56 this->callBack = callBack; 57 } 58 SetType(const int & type)59void TimerInfo::SetType(const int &type) 60 { 61 this->type = type; 62 } 63 SetRepeat(bool repeat)64void TimerInfo::SetRepeat(bool repeat) 65 { 66 this->repeat = repeat; 67 } 68 SetInterval(const uint64_t & interval)69void TimerInfo::SetInterval(const uint64_t &interval) 70 { 71 this->interval = interval; 72 } 73 SetWantAgent(std::shared_ptr<AbilityRuntime::WantAgent::WantAgent> wantAgent)74void TimerInfo::SetWantAgent(std::shared_ptr<AbilityRuntime::WantAgent::WantAgent> wantAgent) 75 { 76 this->wantAgent = wantAgent; 77 } 78 } // namespace Accessibility 79 } // namespace OHOS 80 #endif // TIMER_INFO_H