1/*
2 * Copyright (c) 2023 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 ECMASCRIPT_TOOLING_CLIENT_MANAGER_WATCH_MANAGER_H
16#define ECMASCRIPT_TOOLING_CLIENT_MANAGER_WATCH_MANAGER_H
17
18#include <iostream>
19#include <map>
20#include <memory>
21#include <string>
22#include <vector>
23
24#include "tooling/base/pt_json.h"
25#include "tooling/base/pt_types.h"
26#include "tooling/client/domain/runtime_client.h"
27
28namespace OHOS::ArkCompiler::Toolchain {
29using PtJson = panda::ecmascript::tooling::PtJson;
30using Result = panda::ecmascript::tooling::Result;
31class WatchManager {
32public:
33    explicit WatchManager(uint32_t sessionId);
34    ~WatchManager() = default;
35
36    void SendRequestWatch(const int32_t &watchInfoIndex, const std::string &callFrameId);
37    void GetPropertiesCommand(const int32_t &watchInfoIndex, const std::string &objectId);
38    void RequestWatchInfo(const std::unique_ptr<PtJson> &json);
39    void AddWatchInfo(const std::string& watchInfo);
40
41    bool GetDebugState();
42    void DebugFalseState();
43    void DebugTrueState();
44    bool HandleWatchResult(const std::unique_ptr<PtJson> &json, int32_t id);
45    bool ShowWatchResult(const std::unique_ptr<PtJson> &result, int32_t id);
46    void OutputWatchResult(const std::unique_ptr<PtJson> &watchResult);
47    bool ShowWatchResult2(const int &id, const std::unique_ptr<PtJson> &result);
48    std::string GetCallFrameId();
49    int GetWatchInfoSize();
50    void SetWatchInfoMap(const int &id, const int &index);
51
52private:
53    [[maybe_unused]] int32_t sessionId_;
54    std::vector<std::string> watchInfoList_;
55    std::unordered_map<int, int> watchInfoMap_;
56    bool IsDebug_ = false;
57    std::string callFrameId_;
58    RuntimeClient runtimeClient_;
59    int inputRowFlag_ = 0;
60    bool isShowWatchInfo_ = true;
61};
62} // OHOS::ArkCompiler::Toolchain
63#endif