Code

initial implementation of XML::Subtree API for tracking changes on a
[inkscape.git] / src / xml / subtree.h
1 /*
2  * XML::Subtree - proxy for an XML subtree
3  *
4  * Copyright 2005 MenTaLguY <mental@rydia.net>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * See the file COPYING for details.
12  *
13  */
15 #ifndef SEEN_INKSCAPE_XML_SUBTREE_H
16 #define SEEN_INKSCAPE_XML_SUBTREE_H
18 #include "xml/node-observer.h"
19 #include "xml/composite-node-observer.h"
21 namespace Inkscape {
22 namespace XML {
24 class Node;
26 class Subtree : public Inkscape::GC::Anchored,
27                 public Inkscape::GC::Managed<>,
28                 private NodeObserver
29 {
30 public:
31     Subtree(Node &root);
32     ~Subtree();
34     void finish();
36     void synthesizeEvents(NodeObserver &observer);
37     void addObserver(NodeObserver &observer);
38     void removeObserver(NodeObserver &observer);
40 private:
41     void notifyChildAdded(Node &node, Node &child, Node *prev);
43     void notifyChildRemoved(Node &node, Node &child, Node *prev);
45     void notifyChildOrderChanged(Node &node, Node &child,
46                                  Node *old_prev, Node *new_prev);
48     void notifyContentChanged(Node &node,
49                               Util::ptr_shared<char> old_content,
50                               Util::ptr_shared<char> new_content);
52     void notifyAttributeChanged(Node &node, GQuark name,
53                                 Util::ptr_shared<char> old_value,
54                                 Util::ptr_shared<char> new_value);
56     Node *_root;
57     CompositeNodeObserver _observers;
58 };
60 }
61 }
63 #endif
64 /*
65   Local Variables:
66   mode:c++
67   c-file-style:"stroustrup"
68   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
69   indent-tabs-mode:nil
70   fill-column:99
71   End:
72 */
73 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :