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),
40 void SetProgressFlag(bool flag)
42 m_progressFlag = flag;
44 bool GetProgressFlag() const
46 return m_progressFlag;
49 ProgressDescription GetProgressDescription() const
51 return m_progresDescription;
54 ProgressPercent GetProgressPercent() const
56 return m_progresPercent;
59 void UpdateProgress(T_InstallationStep step,
60 ProgressDescription const &description)
63 ((static_cast<ProgressPercent>(step) + 1.0) /
64 static_cast<ProgressPercent>(lastElement)) * 100;
65 m_progresDescription = description;
69 template<class T_JobStruct>
73 JobContextBase(const T_JobStruct& jobStruct) :
74 m_jobStruct(jobStruct)
78 T_JobStruct getInstallerStruct() const
84 T_JobStruct m_jobStruct;
87 template<typename T_finishedCb, typename T_progressCb>
88 struct JobCallbacksBase
90 T_finishedCb finishedCallback;
91 T_progressCb progressCallback;
94 // It must be empty-constructible as a parameter of generic event
102 JobCallbacksBase(T_finishedCb finished,
103 T_progressCb progress,
105 finishedCallback(finished),
106 progressCallback(progress),
113 #endif // SRC_INSTALLER_CORE_JOBS_JOB_BASE_H