source: source/ariba/utility/visual/OvlVis.h@ 11885

Last change on this file since 11885 was 10653, checked in by Michael Tänzer, 12 years ago

Merge the ASIO branch back into trunk

File size: 8.6 KB
RevLine 
[6584]1// [License]
2// The Ariba-Underlay Copyright
3//
4// Copyright (c) 2008-2009, Institute of Telematics, UniversitÀt Karlsruhe (TH)
5//
6// Institute of Telematics
7// UniversitÀt Karlsruhe (TH)
8// Zirkel 2, 76128 Karlsruhe
9// Germany
10//
11// Redistribution and use in source and binary forms, with or without
12// modification, are permitted provided that the following conditions are
13// met:
14//
15// 1. Redistributions of source code must retain the above copyright
16// notice, this list of conditions and the following disclaimer.
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// THIS SOFTWARE IS PROVIDED BY THE INSTITUTE OF TELEMATICS ``AS IS'' AND
22// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ARIBA PROJECT OR
25// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32//
33// The views and conclusions contained in the software and documentation
34// are those of the authors and should not be interpreted as representing
35// official policies, either expressed or implied, of the Institute of
36// Telematics.
37// [License]
38
39#ifndef OVLVIS_H__
40#define OVLVIS_H__
41
42#include <sstream>
43#include <iostream>
44#include <string>
45#include <map>
46#include <boost/utility.hpp>
47#include "ariba/utility/system/Timer.h"
48#include "ariba/utility/misc/Helper.h"
49#include "ariba/utility/misc/KeyMapping.hpp"
[6822]50#include "ariba/utility/visual/ServerVis.h"
[6584]51
52using std::string;
53using std::map;
54using std::pair;
55using std::make_pair;
56using std::ostringstream;
57using ariba::utility::KeyMapping;
58using ariba::utility::Timer;
59
60namespace ariba {
61namespace utility {
62
[6822]63class OvlVis : public ServerVis, private boost::noncopyable {
[6584]64 use_logging_h(OvlVis);
65public:
66 static OvlVis& instance() { static OvlVis the_inst; return the_inst; }
67
68 //****************************************************************
69 // Node creation, node connections, status, node deletion, ...
70 //****************************************************************
71
72 /**
73 * Create a node in the network that is initially unconnected.
74 */
75 void visCreate (
76 NETWORK_ID network,
77 NodeID& node,
78 string nodename,
79 string info
80 );
81
82 /**
83 * Change the status of a node -> enable/disable a node.
84 */
85 void visChangeStatus(
86 NETWORK_ID network,
87 NodeID& node,
88 bool enable,
89 string info
90 );
91
92 /**
93 * Connect two nodes using a link.
94 */
95 void visConnect (
96 NETWORK_ID network,
97 NodeID& srcnode,
98 NodeID& destnode,
99 string info
100 );
101
102 /**
103 * Disconnect the link between two nodes.
104 */
105 void visDisconnect (
106 NETWORK_ID network,
107 NodeID& srcnode,
108 NodeID& destnode,
109 string info
110 );
111
112 /**
113 * Indicate that the connection procedure
114 * between two nodes failed.
115 */
116 void visFailedConnect (
117 NETWORK_ID network,
118 NodeID& srcnode,
119 NodeID& destnode,
120 string info
121 );
122
123 /**
124 * Delete a node from the network.
125 */
126 void visShutdown (
127 NETWORK_ID network,
128 NodeID& node,
129 string info
130 );
131
132 //****************************************************************
133 // Node manipulation: change color, change icon
134 //****************************************************************
135
136 /**
137 * Change the color of the node.
138 */
139 void visChangeNodeColor (
140 NETWORK_ID network,
141 NodeID& node,
142 unsigned char r,
143 unsigned char g,
144 unsigned char b
145 );
146
147 /**
148 * Change the color of the node.
149 */
150 void visChangeNodeColor (
151 NETWORK_ID network,
152 NodeID& node,
153 NODE_COLORS color
154 );
155
156 /**
157 * The available icons for changing the
158 * icon of a node, showing an icon besides
159 * a node and showing an icon at a link.
160 */
161 typedef enum _ICON_ID {
162 ICON_ID_DEFAULT_NODE = 0,
163 ICON_ID_PC = 1,
164 ICON_ID_PC_WORLD = 2,
165 ICON_ID_FAILURE = 3,
166 ICON_ID_RED_CROSS = 4,
167 ICON_ID_CHARACTER_A = 5,
168 ICON_ID_CHARACTER_W = 6,
169 ICON_ID_CAMERA = 7,
170 } ICON_ID;
171
172 /**
173 * Change the icon of a node.
174 */
175 void visChangeNodeIcon (
176 NETWORK_ID network,
177 NodeID& node,
178 ICON_ID icon
179 );
180
181 /**
182 * Show the label of the node.
183 */
184 void visShowNodeLabel (
185 NETWORK_ID network,
186 NodeID& node,
187 string label
188 );
189
190 /**
191 * Delete the label of the node.
192 */
193 void visDeleteNodeLabel (
194 NETWORK_ID network,
195 NodeID& node
196 );
197
198 /**
199 * Show a bubble at the node.
200 */
201 void visShowNodeBubble (
202 NETWORK_ID network,
203 NodeID& node,
204 string label
205 );
206
207 /**
208 * Delete a bubble at the node.
209 */
210 void visDeleteNodeBubble (
211 NETWORK_ID network,
212 NodeID& node
213 );
214
215 /**
216 * Show an icon besides the node.
217 */
218 void visShowShiftedNodeIcon (
219 NETWORK_ID network,
220 NodeID& node,
221 ICON_ID iconID,
222 unsigned int timeout = 0
223 );
224
225 /**
226 * Delete an icon besides the node
227 */
228 void visDeleteShiftedNodeIcon (
229 NETWORK_ID network,
230 NodeID& node
231 );
232
233 //****************************************************************
234 // Link manipulation: change width, color, show bubbles, icons, ...
235 //****************************************************************
236
237 /**
238 * Change the link width
239 */
240 void visChangeLinkWidth (
241 NETWORK_ID network,
242 NodeID& srcnode,
243 NodeID& destnode,
244 unsigned int width
245 );
246
247 /**
248 * Change the link color
249 */
250 void visChangeLinkColor (
251 NETWORK_ID network,
252 NodeID& srcnode,
253 NodeID& destnode,
254 unsigned char r,
255 unsigned char g,
256 unsigned char b
257 );
258
259 /**
260 * Change the link color
261 */
262 void visChangeLinkColor (
263 NETWORK_ID network,
264 NodeID& srcnode,
265 NodeID& destnode,
266 NODE_COLORS color
267 );
268
269 /**
270 * Show a link label
271 */
272 void visShowLinkLabel (
273 NETWORK_ID network,
274 NodeID& srcnode,
275 NodeID& destnode,
276 string label
277 );
278
279 /**
280 * Delete a link label
281 */
282 void visDeleteLinkLabel (
283 NETWORK_ID network,
284 NodeID& srcnode,
285 NodeID& destnode
286 );
287
288 /**
289 * Show an icon at the link
290 */
291 void visShowOnLinkIcon (
292 NETWORK_ID network,
293 NodeID& srcnode,
294 NodeID& destnode,
295 ICON_ID iconID
296 );
297
298 /**
299 * Delete an icon at the link
300 */
301 void visDeleteOnLinkIcon (
302 NETWORK_ID network,
303 NodeID& srcnode,
304 NodeID& destnode
305 );
306
307 /**
308 * Show a bubble besides the link
309 */
310 void visShowLinkBubble (
311 NETWORK_ID network,
312 NodeID& srcnode,
313 NodeID& destnode,
314 string label
315 );
316
317 /**
318 * Delete a bubble besides the link
319 */
320 void visDeleteLinkBubble (
321 NETWORK_ID network,
322 NodeID& srcnode,
323 NodeID& destnode
324 );
325
326 //****************************************************************
327 // Send message between two nodes
328 //****************************************************************
329
330 /**
331 * Animate the message sending between two nodes
332 */
333 void visSendMessage (
334 NETWORK_ID network,
335 NodeID& startnode,
336 NodeID& endnode
337 );
338
339 //*******************************************************
340 //*
341 void visCLIOInitMeasurement (
342 NETWORK_ID network,
343 unsigned long edgekey,
344 NodeID& srcnode,
345 NodeID& destnode,
346 string info
347 );
348
349 void visCLIOEndMeasurement (
350 NETWORK_ID network,
351 unsigned long edgekey,
352 NodeID& srcnode,
353 NodeID& destnode,
354 string info,
355 string value,
356 string unit
357 );
358 //*
359 //*******************************************************
360
361protected:
362 OvlVis();
[6822]363 virtual ~OvlVis();
[6584]364
365private:
366 void sendMessage( const string msg, NETWORK_ID nid );
367
368 typedef pair<NodeID, NodeID> NodePair;
369 typedef KeyMapping<NodePair> NetworkLinks;
370 typedef KeyMapping<NodePair> LinkBubbles;
371 typedef KeyMapping<NodeID> NodeBubbles;
372 typedef KeyMapping<NodeID> ShiftedNodeIcons;
373 typedef KeyMapping<NodePair> OnLinkIcons;
374
375 NetworkLinks networkLinks;
376 LinkBubbles linkBubbles;
377 NodeBubbles nodeBubbles;
378 ShiftedNodeIcons shiftedNodeIcons;
379 OnLinkIcons onLinkIcons;
380
381 class TimedoutIcon : public Timer {
382 private:
383 NETWORK_ID network;
384 NodeID node;
385 unsigned int timeout;
386 public:
387 TimedoutIcon(NETWORK_ID _network, NodeID _node, unsigned int _timeout) :
388 network(_network), node(_node), timeout(_timeout) {
389 }
390
391 virtual ~TimedoutIcon(){
392 Timer::stop();
393 }
394
395 void startIcon(){
396 Timer::setInterval( timeout, true );
397 Timer::start();
398 }
399
400 protected:
401 virtual void eventFunction(){
402 OvlVis::instance().visDeleteShiftedNodeIcon( network, node );
403 delete this;
404 }
405 };
406
407};
408
409}} // namespace ariba, common
410
411#endif // OVLVIS_H__
Note: See TracBrowser for help on using the repository browser.