An Overlay-based
Virtual Network Substrate
SpoVNet

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

Last change on this file since 6822 was 6822, checked in by Christoph Mayer, 14 years ago

-ovlvis verschoben und 3dvis hinzu

File size: 5.5 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
165protected:
166        DddVis();
167        virtual ~DddVis();
168
169private:
170
171        typedef enum _CommandType {
172                CREATE_LAYER_TYPE                       = 0,
173                CREATE_CLUSTER_TYPE             = 1,
174                CREATE_NODE_TYPE                        = 2,
175                CREATE_EDGE_TYPE                        = 3,
176                REMOVE_LAYER_TYPE                       = 4,
177                REMOVE_CLUSTER_TYPE             = 5,
178                REMOVE_NODE_TYPE                        = 6,
179                REMOVE_EDGE_TYPE                        = 7,
180                SET_CLUSTER_LAYOUT_TYPE         = 8,
181                SET_NODE_COLOR_TYPE             = 9,
182                SET_EDGE_COLOR_TYPE             = 10,
183                SET_NODE_INFO_TYPE                      = 11,
184                SET_EDGE_INFO_TYPE                      = 12,
185                SET_LAYOUT_LEADER_TYPE          = 13,
186        } CommandType;
187
188        typedef enum _LayoutType {
189                CIRCULAR_LAYOUT                         = 0,
190                FORCE_LAYOUT                            = 1,
191                LEADER_LAYOUT                           = 2,
192                RANDOM_LAYOUT                           = 3,
193        } LayoutType;
194
195        typedef enum _LayoutOrderStrategie {
196                ORDER_BY_ID                                     = 0,
197                ORDER_RANDOMLY                          = 1,
198        } LayoutOrderStrategie;
199
200        long getCommandID();
201        long getTimestamp();
202        int makeColor(unsigned char r, unsigned char g, unsigned char b);
203        void sendMessage( const string msg, NETWORK_ID nid );
204        unsigned int getNodeNumber(const NodeID& node);
205
206        unsigned long commandid;
207        static const string del;
208
209        typedef set<ServerVis::NETWORK_ID> LayerSet;
210        LayerSet layerSet;
211
212        typedef map<NodeID,unsigned int> NodeSet;
213        NodeSet nodeSet;
214
215        typedef pair<NodeID, NodeID> NodePair;
216        typedef KeyMapping<NodePair> NetworkLinks;
217        NetworkLinks networkLinks;
218
219
220};
221
222}} // namespace ariba, common
223
224#endif // DDDVIS_H__
Note: See TracBrowser for help on using the repository browser.