blob: da872c5e633c50795c0fdd673c21a84dfc343067 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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 :
|