summaryrefslogtreecommitdiffstats
path: root/src/progs/manager/breakpoint.h
blob: f0f1a5be0363d1d465da9d652f38c25485db3233 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/***************************************************************************
 *   Copyright (C) 2006 Nicolas Hadacek <hadacek@kde.org>                  *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 ***************************************************************************/
#ifndef BREAKPOINT_H
#define BREAKPOINT_H

#include "common/common/storage.h"
#include "common/global/purl.h"
#include "devices/base/generic_device.h"

namespace Breakpoint
{
class List;
enum State { Unknown, Active, Disabled };
enum MarkType { ProgramCounterActive = 0, ProgramCounterDisabled,
                BreakpointActive, BreakpointDisabled, BreakpointReached,
                BreakpointInvalid, Nb_MarkTypes };

//----------------------------------------------------------------------------
class Data {
public:
  Data(const PURL::Url &purl = PURL::Url(), uint pline = 0) : url(purl), line(pline) {}
  bool operator <(const Data &data) const { return ( url<data.url || line<data.line ); }
  bool operator ==(const Data &data) const { return ( url==data.url && line==data.line ); }
  PURL::Url url;
  uint line;
};
extern void updateActions(const Data *data);

//----------------------------------------------------------------------------
class List;
extern List &list();

class List : public GenericStorage
{
Q_OBJECT
  TQ_OBJECT
public:
  List() {}
  void append(const Data &data);
  void remove(const Data &data);
  void clear();
  uint count() const { return _list.count(); }
  const Data &data(uint i) const { return _list[i].data; }
  bool contains(const Data &data) const { return find(data)!=_list.end(); }
  State state(const Data &data) const { return (*find(data)).state; }
  Address address(const Data &data) const { return (*find(data)).address; }
  void setState(const Data &data, State state);
  void setAddress(const Data &data, Address address);

private:
  class StateData {
  public:
    StateData() : state(Unknown) {}
    Data    data;
    Address address;
    State   state;
  };
  TQValueList<StateData> _list;
  TQValueList<StateData>::const_iterator find(const Data &data) const;
  TQValueList<StateData>::iterator find(const Data &data);
};

} // namespace

#endif