1 /* 2 * Copyright (c) 2023-2024 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 OHOS_FORM_FWK_FORM_COMMAND_PROCESS_STRATEGY_H 17 #define OHOS_FORM_FWK_FORM_COMMAND_PROCESS_STRATEGY_H 18 19 #include <queue> 20 21 #include "form_command_queue.h" 22 #include "form_status_mgr.h" 23 24 namespace OHOS { 25 namespace AppExecFwk { 26 27 // Base class for form command processing strategies 28 class FormCommandProcessStrategy { 29 public: 30 virtual ~FormCommandProcessStrategy() = default; 31 virtual void ProcessCommandQueue(std::queue<FormCommand> &commandQueue, const int64_t formId) = 0; 32 33 private: 34 }; 35 36 // Strategy class for RenderForm 37 class RenderFormStrategy : public FormCommandProcessStrategy { 38 public: 39 void ProcessCommandQueue(std::queue<FormCommand> &commandQueue, const int64_t formId) override; 40 }; 41 42 // Strategy class for SimilarStatus 43 class SimilarStatusStrategy : public FormCommandProcessStrategy { 44 public: 45 void ProcessCommandQueue(std::queue<FormCommand> &commandQueue, const int64_t formId) override; 46 }; 47 48 // Strategy class for DifferentStatus 49 class DifferentStatusStrategy : public FormCommandProcessStrategy { 50 public: 51 void ProcessCommandQueue(std::queue<FormCommand> &commandQueue, const int64_t formId) override; 52 }; 53 54 // Factory class for creating form command process strategies 55 class CommandProcessStrategyFactory { 56 public: 57 static std::unique_ptr<FormCommandProcessStrategy> CreateStrategy( 58 TaskCommandType taskCommandType, FormStatus currentFormStatus); 59 }; 60 } 61 } 62 #endif // OHOS_FORM_FWK_FORM_COMMAND_PROCESS_STRATEGY_H 63