summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Debug/Watches.h
blob: cf4ee2b1793dc461d643064f83c2c80452635e63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright 2018 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <cstddef>
#include <span>
#include <string>
#include <vector>

#include "Common/CommonTypes.h"

namespace Common::Debug
{
struct Watch
{
  enum class State : bool
  {
    Enabled = true,
    Disabled = false
  };

  u32 address;
  std::string name;
  State is_enabled;
  bool locked = false;

  Watch(u32 address, std::string name, State is_enabled);
};

class Watches
{
public:
  std::size_t SetWatch(u32 address, std::string name);
  const Watch& GetWatch(std::size_t index) const;
  const std::vector<Watch>& GetWatches() const;
  void UnsetWatch(u32 address);
  void UpdateWatch(std::size_t index, u32 address, std::string name);
  void UpdateWatchAddress(std::size_t index, u32 address);
  void UpdateWatchName(std::size_t index, std::string name);
  void UpdateWatchLockedState(std::size_t index, bool locked);
  void EnableWatch(std::size_t index);
  void DisableWatch(std::size_t index);
  bool HasEnabledWatch(u32 address) const;
  void RemoveWatch(std::size_t index);
  void LoadFromStrings(std::span<const std::string> watches);
  std::vector<std::string> SaveToStrings() const;
  void Clear();

private:
  std::vector<Watch> m_watches;
};
}  // namespace Common::Debug