1 /**
2 * Tracks node add/remove events to an XMLNodeTracker, and eliminates cases such as
3 * consecutive add/remove.
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 #include "xml/node.h"
15 #include "jabber_whiteboard/node-tracker-event-tracker.h"
17 namespace Inkscape {
19 namespace Whiteboard {
21 bool
22 NodeTrackerEventTracker::tryToTrack(XML::Node* node, NodeTrackerAction action)
23 {
24 // 1. Check if node is being tracked.
25 NodeActionMap::iterator i = this->_actions.find(node);
26 if (i != this->_actions.end()) {
27 // 2a. Check the action. If it is the same as the action we are registering,
28 // return false. Otherwise, register the action with the actions map
29 // and return true.
30 if (i->second == action) {
31 return false;
32 } else {
33 this->_actions[node] = action;
34 return true;
35 }
36 } else {
37 // 2b. If we aren't tracking this node, insert it with the given action.
38 this->_actions[node] = action;
39 return true;
40 }
41 }
43 }
45 }
47 /*
48 Local Variables:
49 mode:c++
50 c-file-style:"stroustrup"
51 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
52 indent-tabs-mode:nil
53 fill-column:99
54 End:
55 */
56 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :