100600bfbSopenharmony_ci/*
200600bfbSopenharmony_ci * Copyright (C) 2021-2022 Huawei Device Co., Ltd.
300600bfbSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
400600bfbSopenharmony_ci * you may not use this file except in compliance with the License.
500600bfbSopenharmony_ci * You may obtain a copy of the License at
600600bfbSopenharmony_ci *
700600bfbSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
800600bfbSopenharmony_ci *
900600bfbSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1000600bfbSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1100600bfbSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1200600bfbSopenharmony_ci * See the License for the specific language governing permissions and
1300600bfbSopenharmony_ci * limitations under the License.
1400600bfbSopenharmony_ci */
1500600bfbSopenharmony_ci#ifndef HIDUMPER_SERVICES_DUMP_CFG_H
1600600bfbSopenharmony_ci#define HIDUMPER_SERVICES_DUMP_CFG_H
1700600bfbSopenharmony_ci#include <string>
1800600bfbSopenharmony_ci#include <vector>
1900600bfbSopenharmony_ci#include "common/dumper_constant.h"
2000600bfbSopenharmony_ci#include "common/option_args.h"
2100600bfbSopenharmony_cinamespace OHOS {
2200600bfbSopenharmony_cinamespace HiviewDFX {
2300600bfbSopenharmony_ciclass HidumperExecutor;
2400600bfbSopenharmony_cistruct DumpCfg {
2500600bfbSopenharmony_ci    std::string name_;
2600600bfbSopenharmony_ci    std::string desc_;
2700600bfbSopenharmony_ci    std::string target_;
2800600bfbSopenharmony_ci    std::string section_;
2900600bfbSopenharmony_ci    int class_ {DumperConstant::NONE};
3000600bfbSopenharmony_ci    int level_ {DumperConstant::NONE};
3100600bfbSopenharmony_ci    int loop_ {DumperConstant::NONE};
3200600bfbSopenharmony_ci    std::string filterCfg_;
3300600bfbSopenharmony_ci    std::shared_ptr<OptionArgs> args_;
3400600bfbSopenharmony_ci    int type_ {DumperConstant::NONE}; // DumperConstant::NONE, GROUPTYPE_PID, GROUPTYPE_CPUID
3500600bfbSopenharmony_ci    bool expand_ {false}; // true: expand; false: non-expand
3600600bfbSopenharmony_ci    std::shared_ptr<DumpCfg> parent_;
3700600bfbSopenharmony_ci    std::vector<std::shared_ptr<DumpCfg>> childs_; // GROUP, must clear
3800600bfbSopenharmony_ci    std::shared_ptr<HidumperExecutor> executor_; // GROUP, must clear
3900600bfbSopenharmony_cipublic:
4000600bfbSopenharmony_ci    DumpCfg();
4100600bfbSopenharmony_ci    ~DumpCfg();
4200600bfbSopenharmony_ci    DumpCfg& operator=(const DumpCfg& dumpCfg);
4300600bfbSopenharmony_ci    bool IsGroup() const;
4400600bfbSopenharmony_ci    bool IsDumper() const;
4500600bfbSopenharmony_ci    bool IsFilter() const;
4600600bfbSopenharmony_ci    bool IsLevel() const;
4700600bfbSopenharmony_ci    bool CanLoop() const;
4800600bfbSopenharmony_ci    bool IsOutput() const;
4900600bfbSopenharmony_ci    bool HasPid() const;
5000600bfbSopenharmony_ci    bool HasCpuId() const;
5100600bfbSopenharmony_ci    void Dump(int deep = 0) const;
5200600bfbSopenharmony_ci    static std::shared_ptr<DumpCfg> Create();
5300600bfbSopenharmony_ci    static bool IsDumper(int cls);
5400600bfbSopenharmony_ci    static bool IsFilter(int cls);
5500600bfbSopenharmony_ci    static bool IsLevel(int level);
5600600bfbSopenharmony_ci    static bool CanLoop(int loop);
5700600bfbSopenharmony_ci    static bool IsOutput(int cls);
5800600bfbSopenharmony_ci    static bool HasPid(const std::string &target);
5900600bfbSopenharmony_ci    static bool HasCpuId(const std::string &target);
6000600bfbSopenharmony_ci    static std::string ToStr(int type);
6100600bfbSopenharmony_ci    static void Dump(const DumpCfg& cfg, int nest = 0);
6200600bfbSopenharmony_ciprivate:
6300600bfbSopenharmony_ci    static std::string ToDumperStr(int type);
6400600bfbSopenharmony_ci    static std::string ToFilterStr(int type);
6500600bfbSopenharmony_ci    static std::string ToOutputStr(int type);
6600600bfbSopenharmony_ci    static std::string ToLevelStr(int type);
6700600bfbSopenharmony_ci    static std::string ToTypeStr(int type);
6800600bfbSopenharmony_ci};
6900600bfbSopenharmony_ci} // namespace HiviewDFX
7000600bfbSopenharmony_ci} // namespace OHOS
7100600bfbSopenharmony_ci#endif // HIDUMPER_SERVICES_DUMP_CFG_H
72