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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
#ifndef SEEN_INKSCAPE_XML_SP_REPR_ACTION_H
#define SEEN_INKSCAPE_XML_SP_REPR_ACTION_H
#include <glib/gtypes.h>
#include <glib/gquark.h>
#include <glibmm/ustring.h>
#include <iterator>
#include "util/share.h"
#include "util/forward-pointer-iterator.h"
#include "gc-managed.h"
#include "xml/node.h"
namespace Inkscape {
namespace XML {
class Node;
class NodeObserver;
enum EventType {
EVENT_ADD,
EVENT_DEL,
EVENT_CHG_ATTR,
EVENT_CHG_CONTENT,
EVENT_CHG_ORDER
};
class Event
: public Inkscape::GC::Managed<Inkscape::GC::SCANNED, Inkscape::GC::MANUAL>
{
public:
virtual ~Event() {}
Event *next;
int serial;
Node *repr;
struct IteratorStrategy {
static Event const *next(Event const *action) {
return action->next;
}
};
typedef Inkscape::Util::ForwardPointerIterator<Event, IteratorStrategy> Iterator;
typedef Inkscape::Util::ForwardPointerIterator<Event const, IteratorStrategy> ConstIterator;
Event *optimizeOne() { return _optimizeOne(); }
void undoOne(NodeObserver &observer) const {
_undoOne(observer);
}
void replayOne(NodeObserver &observer) const {
_replayOne(observer);
}
protected:
Event(Node *r, Event *n)
: next(n), serial(_next_serial++), repr(r) {}
virtual Event *_optimizeOne()=0;
virtual void _undoOne(NodeObserver &) const=0;
virtual void _replayOne(NodeObserver &) const=0;
private:
static int _next_serial;
};
class EventAdd : public Event {
public:
EventAdd(Node *repr, Node *c, Node *rr, Event *next)
: Event(repr, next), child(c), ref(rr) {}
Node *child;
Node *ref;
private:
Event *_optimizeOne();
void _undoOne(NodeObserver &observer) const;
void _replayOne(NodeObserver &observer) const;
};
class EventDel : public Event {
public:
EventDel(Node *repr, Node *c, Node *rr, Event *next)
: Event(repr, next), child(c), ref(rr) {}
Node *child;
Node *ref;
private:
Event *_optimizeOne();
void _undoOne(NodeObserver &observer) const;
void _replayOne(NodeObserver &observer) const;
};
class EventChgAttr : public Event {
public:
EventChgAttr(Node *repr, GQuark k,
Inkscape::Util::ptr_shared<char> ov,
Inkscape::Util::ptr_shared<char> nv,
Event *next)
: Event(repr, next), key(k),
oldval(ov), newval(nv) {}
GQuark key;
Inkscape::Util::ptr_shared<char> oldval;
Inkscape::Util::ptr_shared<char> newval;
private:
Event *_optimizeOne();
void _undoOne(NodeObserver &observer) const;
void _replayOne(NodeObserver &observer) const;
};
class EventChgContent : public Event {
public:
EventChgContent(Node *repr,
Inkscape::Util::ptr_shared<char> ov,
Inkscape::Util::ptr_shared<char> nv,
Event *next)
: Event(repr, next), oldval(ov), newval(nv) {}
Inkscape::Util::ptr_shared<char> oldval;
Inkscape::Util::ptr_shared<char> newval;
private:
Event *_optimizeOne();
void _undoOne(NodeObserver &observer) const;
void _replayOne(NodeObserver &observer) const;
};
class EventChgOrder : public Event {
public:
EventChgOrder(Node *repr, Node *c, Node *orr, Node *nrr, Event *next)
: Event(repr, next), child(c),
oldref(orr), newref(nrr) {}
Node *child;
Node *oldref, *newref;
private:
Event *_optimizeOne();
void _undoOne(NodeObserver &observer) const;
void _replayOne(NodeObserver &observer) const;
};
}
}
#endif
|