• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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 #include "applypatch/command_function.h"
17 #include "command_process.h"
18 
19 namespace Updater {
GetCommandFunction(const CommandType type)20 std::unique_ptr<CommandFunction> CommandFunctionFactory::GetCommandFunction(const CommandType type)
21 {
22     switch (type) {
23         case CommandType::ABORT:
24             return std::make_unique<AbortCommandFn>();
25         case CommandType::NEW:
26             return std::make_unique<NewCommandFn>();
27         case CommandType::BSDIFF:
28             return std::make_unique<DiffAndMoveCommandFn>();
29         case CommandType::IMGDIFF:
30             return std::make_unique<DiffAndMoveCommandFn>();
31         case CommandType::ERASE:
32             return std::make_unique<ZeroAndEraseCommandFn>();
33         case CommandType::ZERO:
34             return std::make_unique<ZeroAndEraseCommandFn>();
35         case CommandType::FREE:
36             return std::make_unique<FreeCommandFn>();
37         case CommandType::MOVE:
38             return std::make_unique<DiffAndMoveCommandFn>();
39         case CommandType::STASH:
40             return std::make_unique<StashCommandFn>();
41         default:
42             break;
43     }
44     return nullptr;
45 }
46 
ReleaseCommandFunction(std::unique_ptr<CommandFunction> & instr)47 void CommandFunctionFactory::ReleaseCommandFunction(std::unique_ptr<CommandFunction> &instr)
48 {
49     instr.reset();
50 }
51 }