1 /* 2 * Copyright (C) 2021-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 DUMP_SERVICE_IMPL_H 17 #define DUMP_SERVICE_IMPL_H 18 19 #include <map> 20 #include <memory> 21 #include <iosfwd> 22 #include "dumper_factory.h" 23 24 namespace OHOS::Request::Download { 25 enum DumperType : uint32_t { 26 HELP_DUMPER = 0, 27 TASK_INFO_DUMPER, 28 DUMPER_NUM, 29 }; 30 31 class DumpServiceImpl { 32 public: 33 static DumpServiceImpl &GetInstance(); 34 int Dump(int fd, const std::vector<std::string> &args); 35 private: 36 DumpServiceImpl(); 37 virtual ~DumpServiceImpl(); 38 DumpServiceImpl(DumpServiceImpl const &) = delete; 39 void operator=(DumpServiceImpl const &) = delete; 40 DumpServiceImpl(DumpServiceImpl &&) = delete; 41 DumpServiceImpl &operator=(DumpServiceImpl &&) = delete; 42 43 void InitDumperFactoryMap(); 44 void DumpHelp(int fd) const; 45 DumperType GetDumperType(const std::string &cmd) const; 46 private: 47 using DumperFactoryMap = std::map<DumperType, std::shared_ptr<DumperFactory>>; 48 DumperFactoryMap dumperFactoryMap_; 49 }; 50 } 51 52 #endif // DUMP_SERVICE_IMPL_H 53