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