From 179fa413b047bede6e32109e2ce82437c5fb8d34 Mon Sep 17 00:00:00 2001 From: MenTaLguY Date: Mon, 16 Jan 2006 02:36:01 +0000 Subject: moving trunk for module inkscape (bzr r1) --- .../node-tracker-event-tracker.cpp | 56 ++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/jabber_whiteboard/node-tracker-event-tracker.cpp (limited to 'src/jabber_whiteboard/node-tracker-event-tracker.cpp') 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 + * + * 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 : -- cgit v1.2.3