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