summaryrefslogtreecommitdiffstats
path: root/src/jabber_whiteboard/node-tracker-event-tracker.cpp
diff options
context:
space:
mode:
authorMenTaLguY <mental@rydia.net>2006-01-16 02:36:01 +0000
committermental <mental@users.sourceforge.net>2006-01-16 02:36:01 +0000
commit179fa413b047bede6e32109e2ce82437c5fb8d34 (patch)
treea5a6ac2c1708bd02288fbd8edb2ff500ff2e0916 /src/jabber_whiteboard/node-tracker-event-tracker.cpp
downloadinkscape-179fa413b047bede6e32109e2ce82437c5fb8d34.tar.gz
inkscape-179fa413b047bede6e32109e2ce82437c5fb8d34.zip
moving trunk for module inkscape
(bzr r1)
Diffstat (limited to 'src/jabber_whiteboard/node-tracker-event-tracker.cpp')
-rw-r--r--src/jabber_whiteboard/node-tracker-event-tracker.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/jabber_whiteboard/node-tracker-event-tracker.cpp b/src/jabber_whiteboard/node-tracker-event-tracker.cpp
new file mode 100644
index 000000000..da872c5e6
--- /dev/null
+++ b/src/jabber_whiteboard/node-tracker-event-tracker.cpp
@@ -0,0 +1,56 @@
+/**
+ * Tracks node add/remove events to an XMLNodeTracker, and eliminates cases such as
+ * consecutive add/remove.
+ *
+ * Authors:
+ * David Yip <yipdw@rose-hulman.edu>
+ *
+ * Copyright (c) 2005 Authors
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "xml/node.h"
+
+#include "jabber_whiteboard/node-tracker-event-tracker.h"
+
+namespace Inkscape {
+
+namespace Whiteboard {
+
+bool
+NodeTrackerEventTracker::tryToTrack(XML::Node* node, NodeTrackerAction action)
+{
+ // 1. Check if node is being tracked.
+ NodeActionMap::iterator i = this->_actions.find(node);
+ if (i != this->_actions.end()) {
+ // 2a. Check the action. If it is the same as the action we are registering,
+ // return false. Otherwise, register the action with the actions map
+ // and return true.
+ if (i->second == action) {
+ return false;
+ } else {
+ this->_actions[node] = action;
+ return true;
+ }
+ } else {
+ // 2b. If we aren't tracking this node, insert it with the given action.
+ this->_actions[node] = action;
+ return true;
+ }
+}
+
+}
+
+}
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :