Code

Short term change to allow inkboard to participate in muc at least on gristle.org
[inkscape.git] / src / jabber_whiteboard / serializer.h
1 /**
2  * Inkboard message -> XML::Event* serializer
3  *
4  * Authors:
5  * David Yip <yipdw@rose-hulman.edu>
6  *
7  * Copyright (c) 2005 Authors
8  *
9  * Released under GNU GPL, read the file 'COPYING' for more information
10  */
12 #ifndef __WHITEBOARD_MESSAGE_SERIALIZER_H__
13 #define __WHITEBOARD_MESSAGE_SERIALIZER_H__
15 #include "xml/node-observer.h"
17 #include "util/share.h"
19 #include "jabber_whiteboard/node-tracker.h"
20 #include "jabber_whiteboard/typedefs.h"
21 #include "jabber_whiteboard/node-tracker-observer.h"
23 #include <map>
25 namespace Inkscape {
27 namespace Whiteboard {
29 class Serializer : public NodeTrackerObserver {
30 public:
31         Serializer(XMLNodeTracker* xnt) : NodeTrackerObserver(xnt) { }
32         ~Serializer() { }
34     void notifyChildAdded(XML::Node &node, XML::Node &child, XML::Node *prev);
36     void notifyChildRemoved(XML::Node &node, XML::Node &child, XML::Node *prev);
38     void notifyChildOrderChanged(XML::Node &node, XML::Node &child,
39                                          XML::Node *old_prev, XML::Node *new_prev);
41     void notifyContentChanged(XML::Node &node,
42                                       Util::ptr_shared<char> old_content,
43                                       Util::ptr_shared<char> new_content);
45     void notifyAttributeChanged(XML::Node &node, GQuark name,
46                                         Util::ptr_shared<char> old_value,
47                                         Util::ptr_shared<char> new_value);
49         void synthesizeChildNodeAddEvents();
51         SerializedEventList& getEventList()
52         {
53                 return this->_events;
54         }
56         SerializedEventList getEventListCopy()
57         {
58                 return this->_events;
59         }
61         SerializedEventList getAndClearEventList()
62         {
63                 SerializedEventList ret = this->_events;
64                 this->_events.clear();
65                 return ret;
66         }
68         void clearEventList()
69         {
70                 this->_events.clear();
71         }
73         void clearAttributesScannedBuffer()
74         {
75                 this->_attributes_scanned.clear();
76         }
78         // Convenience method for resetting all stateful aspects of the serializer
79         void reset()
80         {       
81                 g_log(NULL, G_LOG_LEVEL_DEBUG, "Clearing serializer buffers");
82                 this->clearEventList();
83                 this->_parent_child_map.clear();
84                 this->_nn.clear();
85                 this->clearNodeBuffers();
86                 this->clearAttributesScannedBuffer();
87         }
89 private:
90         typedef std::set< XML::Node* > _New_nodes_type;
91         typedef std::map< XML::Node*, XML::Node* > _pc_map_type;
93         SerializedEventList _events;
94         AttributesScannedSet _attributes_scanned;
96         _New_nodes_type _nn;
97         _pc_map_type _parent_child_map;
99         void _newObjectEventHelper(XML::Node& parent, XML::Node& child, XML::Node* prev, bool recurse);
100         void _recursiveMarkAsRemoved(XML::Node& node);
101 };
107 #endif
109 /*
110   Local Variables:
111   mode:c++
112   c-file-style:"stroustrup"
113   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
114   indent-tabs-mode:nil
115   fill-column:99
116   End:
117 */
118 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :