An Overlay-based
Virtual Network Substrate
SpoVNet

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

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

Merge the ASIO branch back into trunk

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