1 /* 2 * Copyright (c) 2023 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 #ifndef DRAWING_COMMAND_H 16 #define DRAWING_COMMAND_H 17 18 #include <iostream> 19 #include <vector> 20 #include <unordered_map> 21 22 namespace OHOS { 23 namespace Rosen { 24 enum class IterateType { 25 ITERATE_FRAME, 26 ITERATE_OPITEM, 27 ITERATE_OPITEM_MANUALLY, 28 OTHER, 29 }; 30 class DCLCommand { 31 public: 32 DCLCommand(int32_t argc, char* argv[]); 33 explicit DCLCommand(std::string commandLine); 34 ~DCLCommand()= default; 35 void ParseCommand(std::vector<std::string> argv); 36 void HandleCommand(std::string option, const std::string& augment); 37 void HandleCommandIterateType(const std::string& inputStr); 38 void CheckParameter(); 39 private: 40 friend class DrawingDCL; 41 enum class CommandType { 42 CT_T, 43 CT_B, 44 CT_E, 45 CT_L, 46 CT_S, 47 CT_I, 48 CT_O, 49 CT_H, 50 }; 51 52 const std::unordered_map<std::string, CommandType> commandMap_ = { 53 { std::string("-t"), CommandType::CT_T }, { std::string("--type"), CommandType::CT_T }, 54 { std::string("-b"), CommandType::CT_B }, { std::string("--beginFrame"), CommandType::CT_B }, 55 { std::string("-e"), CommandType::CT_E }, { std::string("--endFrame"), CommandType::CT_E }, 56 { std::string("-l"), CommandType::CT_L }, { std::string("--loop"), CommandType::CT_L }, 57 { std::string("-s"), CommandType::CT_S }, { std::string("--step"), CommandType::CT_S }, 58 { std::string("-i"), CommandType::CT_I }, { std::string("--inputFilePath"), CommandType::CT_I }, 59 { std::string("-o"), CommandType::CT_O }, { std::string("--outputFilePath"), CommandType::CT_O }, 60 { std::string("-h"), CommandType::CT_H }, { std::string("--help"), CommandType::CT_H }, 61 }; 62 63 const std::string dclMsgErr_ = "error input!\n use command '--help' get more information\n"; 64 const std::string breakLine_ = std::string(80, '-'); 65 const std::string dclMsg_ = "usage: /bin/drawing_engine_sample dcl <option> <argument> \n" + breakLine_ + 66 "\nThere are common commands list:\n" 67 " -t,--type set the type of playback, \n" 68 " \t0: iterate by frame,\n" 69 " \t1: iterate by opItem,\n" 70 " \t2: iterate by opItem using manual control,\n" 71 " -b,--beginFrame set the start number of frames for playback, \n" 72 " -e,--beginFrame set the end number of frames for playback, \n" 73 " -l,--loop set the loops of iterating by frame, \n" 74 " -s,--step set the step when iterating by opItem " 75 "(the step can be a decimal), \n" 76 " -i,--inputFilePath set the input path for drawCmdList files, \n" 77 " -o,--outputFilePath set the output path for drawCmdList files, \n" 78 " -h,--help get help, \n" + breakLine_ + 79 "\nExample: /bin/drawing_ening_sample dcl -t 0 -b 1 -e 100 \n" + breakLine_ + "\n"; 80 81 IterateType iterateType_ = IterateType::ITERATE_FRAME; 82 uint32_t beginFrame_ = 0; 83 uint32_t endFrame_ = 100; 84 uint32_t loop_ = 1; 85 double opItemStep_ = 1; 86 std::string inputFilePath_ = "/data/lkx/"; 87 std::string outputFilePath_ = "/data/lkx/"; 88 }; 89 } 90 } 91 92 93 #endif