1 /** @file
2 * @brief Object representing a subtree of the XML document
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 "gc-managed.h"
19 #include "xml/xml-forward.h"
20 #include "xml/composite-node-observer.h"
22 namespace Inkscape {
23 namespace XML {
25 /**
26 * @brief Represents a node and all its descendants
27 *
28 * This is a convenience object for node operations that affect all of the node's descendants.
29 * Currently the only such operations are adding and removing subtree observers
30 * and synthesizing events for the entire subtree.
31 */
32 class Subtree : public GC::Managed<GC::SCANNED, GC::MANUAL> {
33 public:
34 Subtree(Node &root);
35 ~Subtree();
37 /**
38 * @brief Synthesize events for the entire subtree
39 *
40 * This method notifies the specified observer of node changes equivalent to creating
41 * this subtree from scratch. The notifications recurse into the tree depth-first.
42 * Currently this is the only method that provides extra functionality compared to
43 * the public methods of Node.
44 */
45 void synthesizeEvents(NodeObserver &observer);
46 /**
47 * @brief Add an observer watching for subtree changes
48 *
49 * Equivalent to Node::addSubtreeObserver().
50 */
51 void addObserver(NodeObserver &observer);
52 /**
53 * @brief Add an observer watching for subtree changes
54 *
55 * Equivalent to Node::removeSubtreeObserver().
56 */
57 void removeObserver(NodeObserver &observer);
59 private:
60 Node &_root;
61 CompositeNodeObserver _observers;
62 };
64 }
65 }
67 #endif
68 /*
69 Local Variables:
70 mode:c++
71 c-file-style:"stroustrup"
72 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
73 indent-tabs-mode:nil
74 fill-column:99
75 End:
76 */
77 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :