source: source/ariba/utility/visual/DddVis.h@ 9633

Last change on this file since 9633 was 6954, checked in by Christoph Mayer, 15 years ago

-small visualization enhancements

File size: 5.7 KB
Line 
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 DDDVIS_H__
40#define DDDVIS_H__
41
42#include <sstream>
43#include <iostream>
44#include <string>
45#include <map>
46#include <set>
47#include <boost/utility.hpp>
48#include "ariba/utility/types/NodeID.h"
49#include "ariba/utility/logging/Logging.h"
50#include "ariba/utility/system/Timer.h"
51#include "ariba/utility/misc/Helper.h"
52#include "ariba/utility/misc/KeyMapping.hpp"
53#include "ariba/utility/configuration/Configuration.h"
54#include "ariba/utility/visual/ServerVis.h"
55
56using std::set;
57using std::string;
58using std::map;
59using std::pair;
60using std::make_pair;
61using std::cout;
62using std::ostringstream;
63using ariba::utility::NodeID;
64using ariba::utility::Configuration;
65using ariba::utility::KeyMapping;
66using ariba::utility::Timer;
67
68namespace ariba {
69namespace utility {
70
71class DddVis : public ServerVis, private boost::noncopyable {
72 use_logging_h(DddVis);
73public:
74 static DddVis& instance() { static DddVis the_inst; return the_inst; }
75
76 //****************************************************************
77 // Node creation, node connections, status, node deletion, ...
78 //****************************************************************
79
80 /**
81 * Create a node in the network that is initially unconnected.
82 */
83 void visCreate (
84 NETWORK_ID network,
85 NodeID& node,
86 string nodename,
87 string info
88 );
89
90 /**
91 * Connect two nodes using a link.
92 */
93 void visConnect (
94 NETWORK_ID network,
95 NodeID& srcnode,
96 NodeID& destnode,
97 string info
98 );
99
100 /**
101 * Disconnect the link between two nodes.
102 */
103 void visDisconnect (
104 NETWORK_ID network,
105 NodeID& srcnode,
106 NodeID& destnode,
107 string info
108 );
109
110 /**
111 * Delete a node from the network.
112 */
113 void visShutdown (
114 NETWORK_ID network,
115 NodeID& node,
116 string info
117 );
118
119 //****************************************************************
120 // Node manipulation: change color, change icon
121 //****************************************************************
122
123 /**
124 * Change the color of the node.
125 */
126 void visChangeNodeColor (
127 NETWORK_ID network,
128 NodeID& node,
129 unsigned char r,
130 unsigned char g,
131 unsigned char b
132 );
133
134 /**
135 * Change the color of the node.
136 */
137 void visChangeNodeColor (
138 NETWORK_ID network,
139 NodeID& node,
140 NODE_COLORS color
141 );
142
143 /**
144 * Change the link color
145 */
146 void visChangeLinkColor (
147 NETWORK_ID network,
148 NodeID& srcnode,
149 NodeID& destnode,
150 unsigned char r,
151 unsigned char g,
152 unsigned char b
153 );
154
155 /**
156 * Change the link color
157 */
158 void visChangeLinkColor (
159 NETWORK_ID network,
160 NodeID& srcnode,
161 NodeID& destnode,
162 NODE_COLORS color
163 );
164
165 /**
166 * Show the label of the node
167 */
168 void visShowNodeLabel (
169 NETWORK_ID network,
170 NodeID& node,
171 string label
172 );
173
174protected:
175 DddVis();
176 virtual ~DddVis();
177
178private:
179
180 typedef enum _CommandType {
181 CREATE_LAYER_TYPE = 0,
182 CREATE_CLUSTER_TYPE = 1,
183 CREATE_NODE_TYPE = 2,
184 CREATE_EDGE_TYPE = 3,
185 REMOVE_LAYER_TYPE = 4,
186 REMOVE_CLUSTER_TYPE = 5,
187 REMOVE_NODE_TYPE = 6,
188 REMOVE_EDGE_TYPE = 7,
189 SET_CLUSTER_LAYOUT_TYPE = 8,
190 SET_NODE_COLOR_TYPE = 9,
191 SET_EDGE_COLOR_TYPE = 10,
192 SET_NODE_INFO_TYPE = 11,
193 SET_EDGE_INFO_TYPE = 12,
194 SET_LAYOUT_LEADER_TYPE = 13,
195 } CommandType;
196
197 typedef enum _LayoutType {
198 CIRCULAR_LAYOUT = 0,
199 FORCE_LAYOUT = 1,
200 LEADER_LAYOUT = 2,
201 RANDOM_LAYOUT = 3,
202 } LayoutType;
203
204 typedef enum _LayoutOrderStrategie {
205 ORDER_BY_ID = 0,
206 ORDER_RANDOMLY = 1,
207 } LayoutOrderStrategie;
208
209 long getCommandID();
210 long getTimestamp();
211 int makeColor(unsigned char r, unsigned char g, unsigned char b);
212 void sendMessage( const string msg, NETWORK_ID nid );
213 unsigned int getNodeNumber(const NodeID& node);
214
215 unsigned long commandid;
216 static const string del;
217
218 typedef set<ServerVis::NETWORK_ID> LayerSet;
219 LayerSet layerSet;
220
221 typedef map<NodeID,unsigned int> NodeSet;
222 NodeSet nodeSet;
223
224 typedef pair<NodeID, NodeID> NodePair;
225 typedef KeyMapping<NodePair> NetworkLinks;
226 NetworkLinks networkLinks;
227};
228
229}} // namespace ariba, common
230
231#endif // DDDVIS_H__
Note: See TracBrowser for help on using the repository browser.