2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 #ifndef SRC_INSTALLER_CORE_JOBS_JOB_BASE_H
17 #define SRC_INSTALLER_CORE_JOBS_JOB_BASE_H
21 typedef std::string ProgressDescription;
22 typedef float ProgressPercent;
25 template<typename T_InstallationStep,
26 T_InstallationStep lastElement>
31 ProgressDescription m_progresDescription;
32 ProgressPercent m_progresPercent;
35 JobProgressBase() : m_progressFlag(false),
39 void SetProgressFlag(bool flag)
41 m_progressFlag = flag;
43 bool GetProgressFlag() const
45 return m_progressFlag;
48 ProgressDescription GetProgressDescription() const
50 return m_progresDescription;
53 ProgressPercent GetProgressPercent() const
55 return m_progresPercent;
58 void UpdateProgress(T_InstallationStep step,
59 ProgressDescription const &description)
62 ((static_cast<ProgressPercent>(step) + 1.0) /
63 static_cast<ProgressPercent>(lastElement)) * 100;
64 m_progresDescription = description;
68 template<class T_JobStruct>
72 JobContextBase(const T_JobStruct& jobStruct) :
73 m_jobStruct(jobStruct)
76 T_JobStruct getInstallerStruct() const
83 T_JobStruct m_jobStruct;
86 template<typename T_finishedCb, typename T_progressCb>
87 struct JobCallbacksBase
89 T_finishedCb finishedCallback;
90 T_progressCb progressCallback;
93 // It must be empty-constructible as a parameter of generic event
100 JobCallbacksBase(T_finishedCb finished,
101 T_progressCb progress,
103 finishedCallback(finished),
104 progressCallback(progress),
110 #endif // SRC_INSTALLER_CORE_JOBS_JOB_BASE_H