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#ifndef HIDUMPER_SERVICES_OPTION_ARGS_H
16#define HIDUMPER_SERVICES_OPTION_ARGS_H
17#include <string>
18#include <vector>
19#include "common/dumper_constant.h"
20namespace OHOS {
21namespace HiviewDFX {
22class OptionArgs {
23public:
24    OptionArgs();
25    virtual ~OptionArgs();
26    OptionArgs& operator=(const OptionArgs& optArgs);
27
28    bool HasPid() const;
29    void SetPid(int pid, int uid);
30    int GetPid() const;
31    int GetUid() const;
32
33    bool HasCpuId() const;
34    void SetCpuId(int cpuid);
35    int GetCpuId() const;
36
37    bool HasStr() const;
38    void SetStr(const std::string& str);
39    const std::string& GetStr() const;
40
41    bool HasStrList() const;
42    void SetStrList(const std::vector<std::string>& list);
43    const std::vector<std::string>& GetStrList() const;
44
45    bool HasNamesAndArgs() const;
46    void SetNamesAndArgs(const std::vector<std::string>& names, const std::vector<std::string>& args);
47    const std::vector<std::string>& GetNameList() const;
48    const std::vector<std::string>& GetArgList() const;
49
50    void Dump() const;
51    static std::shared_ptr<OptionArgs> Create();
52    static std::shared_ptr<OptionArgs> Clone(std::shared_ptr<OptionArgs>& args);
53private:
54    static const int UNSET = -1;
55    int type_ {DumperConstant::NONE};
56    bool hasPid_ {false};
57    int pid_ {UNSET};
58    int uid_ {UNSET};
59    bool hasCpuId_ {false};
60    int cpuId_ {UNSET};
61    bool hasStr_ {false};
62    std::string str_;
63    bool hasList_ {false};
64    std::vector<std::string> list_;
65    bool hasNamesAndArgs_ {false};
66    std::vector<std::string> names_;
67    std::vector<std::string> args_;
68};
69} // namespace HiviewDFX
70} // namespace OHOS
71#endif // HIDUMPER_SERVICES_OPTION_ARGS_H
72