Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
event.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
/*
5 * Authors:
6 * Unknown author(s)
7 * Krzysztof KosiƄski <tweenk.pl@gmail.com> (documentation)
8 *
9 * Copyright (C) 2018 Authors
10 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
11 */
12
13#ifndef SEEN_INKSCAPE_XML_SP_REPR_ACTION_H
14#define SEEN_INKSCAPE_XML_SP_REPR_ACTION_H
15
16typedef unsigned int GQuark;
17#include <glibmm/ustring.h>
18
19#include <iterator>
20#include "util/share.h"
22#include "inkgc/gc-managed.h"
23#include "xml/node.h"
24
25namespace Inkscape {
26namespace XML {
27
31// enum EventType {
32// EVENT_ADD, ///< Child added
33// EVENT_DEL, ///< Child removed
34// EVENT_CHG_ATTR, ///< Attribute changed
35// EVENT_CHG_CONTENT, ///< Content changed
36// EVENT_CHG_ORDER ///< Order of children changed
37// };
38
51class Event
52: public Inkscape::GC::Managed<Inkscape::GC::SCANNED, Inkscape::GC::MANUAL>
53{
54public:
55 virtual ~Event() = default;
56
67 int serial;
76
78 static Event const *next(Event const *action) {
79 return action->next;
80 }
81 };
82
85
99 }
108
109protected:
111 : next(n), serial(_next_serial++), repr(r) {}
112
113 virtual Event *_optimizeOne()=0;
114 virtual void _undoOne(NodeObserver &) const=0;
115 virtual void _replayOne(NodeObserver &) const=0;
116
117private:
118 static int _next_serial;
119};
120
124class EventAdd : public Event {
125public:
127 : Event(repr, next), child(c), ref(rr) {}
128
133
134private:
135 Event *_optimizeOne() override;
136 void _undoOne(NodeObserver &observer) const override;
137 void _replayOne(NodeObserver &observer) const override;
138};
139
143class EventDel : public Event {
144public:
146 : Event(repr, next), child(c), ref(rr) {}
147
152
153private:
154 Event *_optimizeOne() override;
155 void _undoOne(NodeObserver &observer) const override;
156 void _replayOne(NodeObserver &observer) const override;
157};
158
162class EventChgAttr : public Event {
163public:
170
177
178private:
179 Event *_optimizeOne() override;
180 void _undoOne(NodeObserver &observer) const override;
181 void _replayOne(NodeObserver &observer) const override;
182};
183
187class EventChgContent : public Event {
188public:
194
199
200private:
201 Event *_optimizeOne() override;
202 void _undoOne(NodeObserver &observer) const override;
203 void _replayOne(NodeObserver &observer) const override;
204};
205
209class EventChgOrder : public Event {
210public:
212 : Event(repr, next), child(c),
213 oldref(orr), newref(nrr) {}
214
221
222private:
223 Event *_optimizeOne() override;
224 void _undoOne(NodeObserver &observer) const override;
225 void _replayOne(NodeObserver &observer) const override;
226};
227
232public:
235
240
241private:
242 Event* _optimizeOne() override;
243 void _undoOne(NodeObserver& observer) const override;
244 void _replayOne(NodeObserver& observer) const override;
245};
246
247}
248}
249
250#endif
251/*
252 Local Variables:
253 mode:c++
254 c-file-style:"stroustrup"
255 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
256 indent-tabs-mode:nil
257 fill-column:99
258 End:
259*/
260// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
A base class for objects for whom the normal new and delete operators should use the garbage-collecte...
Definition gc-managed.h:27
Object representing child addition.
Definition event.h:124
void _undoOne(NodeObserver &observer) const override
Definition event.cpp:154
Node * ref
The node after which the child has been added, or NULL if it was added as first.
Definition event.h:132
void _replayOne(NodeObserver &observer) const override
Definition event.cpp:222
EventAdd(Node *repr, Node *c, Node *rr, Event *next)
Definition event.h:126
Node * child
The added child node.
Definition event.h:130
Event * _optimizeOne() override
Definition event.cpp:335
Object representing attribute change.
Definition event.h:162
Inkscape::Util::ptr_shared oldval
Value of the attribute before the change.
Definition event.h:174
void _undoOne(NodeObserver &observer) const override
Definition event.cpp:166
GQuark key
GQuark corresponding to the changed attribute's name.
Definition event.h:172
Event * _optimizeOne() override
Definition event.cpp:343
void _replayOne(NodeObserver &observer) const override
Definition event.cpp:234
Inkscape::Util::ptr_shared newval
Value of the attribute after the change.
Definition event.h:176
EventChgAttr(Node *repr, GQuark k, Inkscape::Util::ptr_shared ov, Inkscape::Util::ptr_shared nv, Event *next)
Definition event.h:164
Object representing content change.
Definition event.h:187
Inkscape::Util::ptr_shared newval
Content of the node after the change.
Definition event.h:198
EventChgContent(Node *repr, Inkscape::Util::ptr_shared ov, Inkscape::Util::ptr_shared nv, Event *next)
Definition event.h:189
Inkscape::Util::ptr_shared oldval
Content of the node before the change.
Definition event.h:196
void _undoOne(NodeObserver &observer) const override
Definition event.cpp:172
Event * _optimizeOne() override
Definition event.cpp:363
void _replayOne(NodeObserver &observer) const override
Definition event.cpp:240
Object representing element name change.
Definition event.h:231
void _replayOne(NodeObserver &observer) const override
Definition event.cpp:252
GQuark new_name
GQuark corresponding to the new element name.
Definition event.h:239
void _undoOne(NodeObserver &observer) const override
Definition event.cpp:184
EventChgElementName(Node *repr, GQuark old_name, GQuark new_name, Event *next)
Definition event.h:233
Event * _optimizeOne() override
Definition event.cpp:417
GQuark old_name
GQuark corresponding to the old element name.
Definition event.h:237
Object representing child order change.
Definition event.h:209
Node * oldref
The node after which the relocated node was in the sibling order before the change,...
Definition event.h:218
Node * child
The node that was relocated in sibling order.
Definition event.h:216
Node * newref
The node after which the relocated node is after the change, or if it's first.
Definition event.h:220
EventChgOrder(Node *repr, Node *c, Node *orr, Node *nrr, Event *next)
Definition event.h:211
void _replayOne(NodeObserver &observer) const override
Definition event.cpp:246
Event * _optimizeOne() override
Definition event.cpp:381
void _undoOne(NodeObserver &observer) const override
Definition event.cpp:178
Object representing child removal.
Definition event.h:143
void _replayOne(NodeObserver &observer) const override
Definition event.cpp:228
Event * _optimizeOne() override
Definition event.cpp:339
Node * child
The child node that was removed.
Definition event.h:149
EventDel(Node *repr, Node *c, Node *rr, Event *next)
Definition event.h:145
Node * ref
The node after which the removed node was in the sibling order, or NULL if it was first.
Definition event.h:151
void _undoOne(NodeObserver &observer) const override
Definition event.cpp:160
Enumeration of all XML event types.
Definition event.h:53
Inkscape::Util::ForwardPointerIterator< Event, IteratorStrategy > Iterator
Definition event.h:83
void undoOne(NodeObserver &observer) const
Undo this event to an observer.
Definition event.h:97
virtual Event * _optimizeOne()=0
Inkscape::Util::ForwardPointerIterator< Event const, IteratorStrategy > ConstIterator
Definition event.h:84
Event * optimizeOne()
If possible, combine this event with the next to reduce memory use.
Definition event.h:90
static int _next_serial
Definition event.h:118
Event * next
Pointer to the next event in the event chain.
Definition event.h:63
virtual void _undoOne(NodeObserver &) const =0
virtual void _replayOne(NodeObserver &) const =0
void replayOne(NodeObserver &observer) const
Replay this event to an observer.
Definition event.h:105
Node * repr
Pointer to the node that was the object of the event.
Definition event.h:75
int serial
Serial number of the event, not used at the moment.
Definition event.h:67
Event(Node *r, Event *n)
Definition event.h:110
virtual ~Event()=default
Interface for XML node observers.
Interface for refcounted XML nodes.
Definition node.h:80
NodeObserver const * observer
double c[8][4]
Base class for GC-managed objects.
Helper class to stream background task notifications as a series of messages.
guint32 GQuark
static Event const * next(Event const *action)
Definition event.h:78
unsigned int GQuark
Definition event.h:16
Interface for XML nodes.