11401458bSopenharmony_ci/*
21401458bSopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd.
31401458bSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
41401458bSopenharmony_ci * you may not use this file except in compliance with the License.
51401458bSopenharmony_ci * You may obtain a copy of the License at
61401458bSopenharmony_ci *
71401458bSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
81401458bSopenharmony_ci *
91401458bSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
101401458bSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
111401458bSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
121401458bSopenharmony_ci * See the License for the specific language governing permissions and
131401458bSopenharmony_ci * limitations under the License.
141401458bSopenharmony_ci */
151401458bSopenharmony_ci
161401458bSopenharmony_ci#ifndef HISYSEVENT_TOOL_H
171401458bSopenharmony_ci#define HISYSEVENT_TOOL_H
181401458bSopenharmony_ci
191401458bSopenharmony_ci#include <functional>
201401458bSopenharmony_ci#include <map>
211401458bSopenharmony_ci#include <string>
221401458bSopenharmony_ci#include <thread>
231401458bSopenharmony_ci
241401458bSopenharmony_ci#include "hisysevent_manager.h"
251401458bSopenharmony_ci
261401458bSopenharmony_cinamespace OHOS {
271401458bSopenharmony_cinamespace HiviewDFX {
281401458bSopenharmony_cistruct ArgStuct {
291401458bSopenharmony_ci    bool real;
301401458bSopenharmony_ci    bool checkValidEvent;
311401458bSopenharmony_ci    std::string domain;
321401458bSopenharmony_ci    std::string eventName;
331401458bSopenharmony_ci    std::string tag;
341401458bSopenharmony_ci    RuleType ruleType;
351401458bSopenharmony_ci    bool history;
361401458bSopenharmony_ci    bool isDebug;
371401458bSopenharmony_ci    long long beginTime;
381401458bSopenharmony_ci    long long endTime;
391401458bSopenharmony_ci    int maxEvents;
401401458bSopenharmony_ci    uint32_t eventType;
411401458bSopenharmony_ci};
421401458bSopenharmony_ci
431401458bSopenharmony_ciusing OptHandler = std::function<void(struct ArgStuct&, const char*)>;
441401458bSopenharmony_ci
451401458bSopenharmony_ciclass HiSysEventTool {
461401458bSopenharmony_cipublic:
471401458bSopenharmony_ci    HiSysEventTool(bool autoExit = true);
481401458bSopenharmony_ci    ~HiSysEventTool() {}
491401458bSopenharmony_ci
501401458bSopenharmony_cipublic:
511401458bSopenharmony_ci    void DoCmdHelp();
521401458bSopenharmony_ci    bool DoAction();
531401458bSopenharmony_ci    void NotifyClient();
541401458bSopenharmony_ci    bool ParseCmdLine(int argc, char** argv);
551401458bSopenharmony_ci    void WaitClient();
561401458bSopenharmony_ci
571401458bSopenharmony_ciprivate:
581401458bSopenharmony_ci    bool CheckCmdLine();
591401458bSopenharmony_ci    void HandleInput(int argc, char** argv, const char* selection);
601401458bSopenharmony_ci
611401458bSopenharmony_ciprivate:
621401458bSopenharmony_ci    struct ArgStuct clientCmdArg;
631401458bSopenharmony_ci    bool autoExit = true;
641401458bSopenharmony_ci    std::condition_variable condvClient;
651401458bSopenharmony_ci    std::mutex mutexClient;
661401458bSopenharmony_ci    std::map<int, OptHandler> optHandlers;
671401458bSopenharmony_ci};
681401458bSopenharmony_ci} // namespace HiviewDFX
691401458bSopenharmony_ci} // namespace OHOS
701401458bSopenharmony_ci
711401458bSopenharmony_ci#endif // HISYSEVENT_TOOL_H
72