• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 FOUNDATION_APPEXECFWK_SERVICES_FORMMGR_INCLUDE_FORM_TIMER_INFO_H
17 #define FOUNDATION_APPEXECFWK_SERVICES_FORMMGR_INCLUDE_FORM_TIMER_INFO_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<OHOS::Notification::WantAgent::WantAgent> wantAgent) override;
36     void SetCallbackInfo(std::function<void()> callBack);
37 
38     private:
39         std::function<void()> callBack;
40 };
41 
FormTimerOption()42 FormTimerOption::FormTimerOption()
43 {
44 }
45 
~FormTimerOption()46 FormTimerOption::~FormTimerOption()
47 {
48 }
49 
OnTrigger()50 void FormTimerOption::OnTrigger()
51 {
52     callBack();
53 }
54 
SetCallbackInfo(std::function<void ()> callBack)55 void FormTimerOption::SetCallbackInfo(std::function<void()> callBack)
56 {
57     this->callBack = callBack;
58 }
59 
SetType(const int & type)60 void FormTimerOption::SetType(const int &type)
61 {
62     this->type = type;
63 }
64 
SetRepeat(bool repeat)65 void FormTimerOption::SetRepeat(bool repeat)
66 {
67     this->repeat = repeat;
68 }
SetInterval(const uint64_t & interval)69 void FormTimerOption::SetInterval(const uint64_t &interval)
70 {
71     this->interval = interval;
72 }
SetWantAgent(std::shared_ptr<OHOS::Notification::WantAgent::WantAgent> _wantAgent)73 void FormTimerOption::SetWantAgent(std::shared_ptr<OHOS::Notification::WantAgent::WantAgent> _wantAgent)
74 {
75     this->wantAgent = _wantAgent;
76 }
77 
78 }  // namespace AppExecFwk
79 }  // namespace OHOS
80 
81 #endif // FOUNDATION_APPEXECFWK_SERVICES_FORMMGR_INCLUDE_FORM_TIMER_INFO_H
82