• 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 PROGRESS_STRATEGY_H
17 #define PROGRESS_STRATEGY_H
18 
19 #include <memory>
20 #include "page/page_manager.h"
21 #include "updater_ui.h"
22 
23 namespace Updater {
24 class ProgressStrategy {
25 public:
ProgressStrategy(const ComInfo & id)26     explicit ProgressStrategy(const ComInfo &id) : id_ {id}, pgMgr_ {PageManager::GetInstance()} {}
27     virtual ~ProgressStrategy() = default;
28     virtual void ShowProgress(float value) const = 0;
29     void Show() const;
30     void Hide() const;
31     static std::unique_ptr<ProgressStrategy> Factory(const std::string &type, const ComInfo &id);
32 protected:
33     ComInfo id_;
34     PageManager &pgMgr_;
35 };
36 
37 class TxtProgress final : public ProgressStrategy {
38 public:
TxtProgress(const ComInfo & id)39     explicit TxtProgress(const ComInfo &id) : ProgressStrategy(id) { }
40     ~TxtProgress() override = default;
41     void ShowProgress(float value) const override;
42 };
43 
44 class BarProgress final : public ProgressStrategy {
45 public:
46     explicit BarProgress(const ComInfo &id);
47     ~BarProgress() override = default;
48     void ShowProgress(float value) const override;
49 };
50 } // namespace Updater
51 #endif
52