• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 SYS_INSTALLER_I_ACTION_H
17 #define SYS_INSTALLER_I_ACTION_H
18 
19 #include <cstdio>
20 #include "error_code.h"
21 #include "sys_installer_common.h"
22 
23 namespace OHOS {
24 namespace SysInstaller {
25 using ActionCallbackFun = std::function<void (InstallerErrCode, const std::string &)>;
26 
27 class IAction {
28 public:
29     IAction() = default;
30     virtual ~IAction() = default;
31 
SetCallback(ActionCallbackFun actionCallBack)32     virtual void SetCallback(ActionCallbackFun actionCallBack)
33     {
34         actionCallBack_ = actionCallBack;
35     }
36     virtual void PerformAction() = 0;
37     virtual std::string GetActionName() = 0;
TerminateAction()38     virtual bool TerminateAction()
39     {
40         return false;
41     };
SuspendAction()42     virtual void SuspendAction() {}
ResumeAction()43     virtual void ResumeAction() {}
GetErrorStr()44     virtual std::string GetErrorStr()
45     {
46         return "";
47     }
SetCpuAffinityAction(unsigned int reservedCores)48     virtual bool SetCpuAffinityAction(unsigned int reservedCores)
49     {
50         return false;
51     }
52 
53 protected:
54     ActionCallbackFun actionCallBack_;
55 };
56 } // SysInstaller
57 } // namespace OHOS
58 #endif // SYS_INSTALLER_I_ACTION_H
59