1 /**
2 * Whiteboard session manager
3 * XML node tracking facility
4 *
5 * Authors:
6 * David Yip <yipdw@rose-hulman.edu>
7 *
8 * Copyright (c) 2005 Authors
9 *
10 * Released under GNU GPL, read the file 'COPYING' for more information
11 */
13 #ifndef __WHITEBOARD_TRACKER_NODE_H__
14 #define __WHITEBOARD_TRACKER_NODE_H__
16 #include "xml/node.h"
18 #include "gc-managed.h"
19 #include "gc-finalized.h"
21 #include <glibmm.h>
22 #include <bitset>
24 namespace Inkscape {
26 namespace Whiteboard {
28 // set _size in TrackerNode private members if you add or delete
29 // any more listeners
30 enum ListenerType {
31 ATTR_CHANGED,
32 CHILD_ADDED,
33 CHILD_REMOVED,
34 CHILD_ORDER_CHANGED,
35 CONTENT_CHANGED
36 };
38 struct TrackerNode : public GC::Managed<> {
39 public:
40 TrackerNode(XML::Node const* n) : _node(n)
41 {
42 }
44 ~TrackerNode()
45 {
46 }
48 void lock(ListenerType listener)
49 {
50 if (listener < _size) {
51 this->_listener_locks.set(listener, true);
52 }
53 }
55 void unlock(ListenerType listener)
56 {
57 if (listener < _size) {
58 this->_listener_locks.set(listener, false);
59 }
60 }
62 bool isLocked(ListenerType listener)
63 {
64 return (this->_listener_locks[listener]);
65 }
67 XML::Node const* _node;
69 private:
70 // change this if any other flags are added
71 static unsigned short const _size = 5;
72 std::bitset< _size > _listener_locks;
74 // noncopyable, nonassignable
75 TrackerNode(TrackerNode const&);
76 TrackerNode& operator=(TrackerNode const&);
77 };
79 }
81 }
83 #endif
85 /*
86 Local Variables:
87 mode:c++
88 c-file-style:"stroustrup"
89 c-file-offsets:((innamespace . 0)(inline-open . 0))
90 indent-tabs-mode:nil
91 fill-column:99
92 End:
93 */
94 // vim: filetype=c++:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :