1 /* 2 * rea.h -- 3 * 4 * Common header-file for dump-cm.c and dump-svg.c. 5 * 6 * Copyright (c) 2000 A. Mueller, Technical University of Braunschweig. 7 * Copyright (c) 2005 K. Sperner, Technical University of Braunschweig. 8 * 9 * See the file "COPYING" for information on usage and redistribution 10 * of this file, and for a DISCLAIMER OF ALL WARRANTIES. 11 * 12 * @(#) $Id: rea.h 7382 2007-10-19 23:40:24Z schoenw $ 13 */ 14 15 #ifndef _REA_H 16 #define _REA_H 17 18 #include <config.h> 19 20 #include <stdio.h> 21 #include <stdlib.h> 22 #include <string.h> 23 #include <ctype.h> 24 #ifdef HAVE_WIN_H 25 #include "win.h" 26 #endif 27 28 #include "smi.h" 29 #include "smidump.h" 30 31 32 33 #define ABS(a) ((float)((a > 0.0) ? (a) : (-(a)))) 34 35 36 37 typedef enum GraphCardinality { 38 GRAPH_CARD_UNKNOWN = 0, 39 GRAPH_CARD_ONE_TO_ONE = 1, 40 GRAPH_CARD_ONE_TO_MANY = 2, 41 GRAPH_CARD_ZERO_TO_ONE = 3, 42 GRAPH_CARD_ZERO_TO_MANY = 4, 43 GRAPH_CARD_ONE_TO_ZERO_OR_ONE = 5 44 } GraphCardinality; 45 46 typedef enum GraphConnection { 47 GRAPH_CON_UNKNOWN = 0, 48 GRAPH_CON_AGGREGATION = 1, 49 GRAPH_CON_DEPENDENCY = 2, 50 GRAPH_CON_ASSOCIATION = 3 51 } GraphConnection; 52 53 typedef enum GraphEnhIndex { 54 GRAPH_ENHINDEX_UNKNOWN = 0, 55 GRAPH_ENHINDEX_NOTIFICATION = 1, 56 GRAPH_ENHINDEX_TYPES = 2, 57 GRAPH_ENHINDEX_NAMES = 3, 58 GRAPH_ENHINDEX_INDEX = 4, 59 GRAPH_ENHINDEX_REROUTE = 5, 60 GRAPH_ENHINDEX_POINTER = 6 61 } GraphEnhIndex; 62 63 /* 64 * Definition used by the dia output driver. 65 */ 66 67 #define DIA_PRINT_FLAG 0x01 68 69 typedef struct DiaNode { 70 int flags; /* flags for the dia xml output driver */ 71 float x,y; /* coordinates (left upper corner) */ 72 float xDisp,yDisp; /* displacement vector for springembedder */ 73 float w,h; /* width and height of the dia node */ 74 int relatedScalars; /* has related scalars -> print them */ 75 int indexObjects; /* has index objects -> print them */ 76 } DiaNode; 77 78 typedef struct DiaEdge { 79 int flags; /* flags for the dia xml output driver */ 80 float startX, startY; /* Intersection of edge and startNode */ 81 float endX, endY; /* Intersection of edge and endNode */ 82 } DiaEdge; 83 84 /* 85 * Generic structure for moduleInformation string-lists. 86 */ 87 88 typedef struct StringListElem { 89 struct StringListElem *nextPtr; 90 SmiStatus status; 91 char *miElem; 92 } StringListElem; 93 94 /* 95 * Generic structures for the internal graph representation. 96 */ 97 98 typedef struct GraphComponent { 99 struct GraphComponent *nextPtr; 100 struct GraphNode *firstComponentNode; 101 float xMin; 102 float xMax; 103 float yMin; 104 float yMax; 105 float xOffset; 106 float yOffset; 107 } GraphComponent; 108 109 typedef struct GraphNode { 110 struct GraphNode *nextPtr; 111 SmiNode *smiNode; 112 SmiModule *smiModule; 113 int group; /* group number of this graph node */ 114 int use; /* use node in the layout-algorithm */ 115 int degree; /* quantity of adjacent nodes */ 116 GraphComponent *component; /* component the node belongs to */ 117 struct GraphNode *nextComponentNode; 118 DiaNode dia; 119 } GraphNode; 120 121 typedef struct GraphEdge { 122 struct GraphEdge *nextPtr; 123 GraphNode *startNode; 124 GraphNode *endNode; 125 SmiIndexkind indexkind; 126 GraphConnection connection; 127 GraphCardinality cardinality; 128 GraphEnhIndex enhancedindex; 129 int use; /* use edge in the layout-algorithm */ 130 DiaEdge dia; 131 } GraphEdge; 132 133 typedef struct Graph { 134 GraphNode *nodes; 135 GraphEdge *edges; 136 GraphComponent *components; 137 } Graph; 138 139 140 141 /* 142 * driver output control 143 */ 144 extern int CANVASHEIGHT; 145 extern int CANVASWIDTH; 146 extern int SHOW_DEPRECATED; 147 extern int SHOW_DEPR_OBSOLETE; 148 extern int STATIC_OUTPUT; 149 extern int XPLAIN; 150 extern int XPLAIN_DEBUG; 151 extern int SUPPRESS_DEPRECATED; 152 extern int PRINT_DETAILED_ATTR; 153 extern int IGNORE_IMPORTED_NODES; 154 155 156 /* 157 * global variables 158 */ 159 extern Graph *graph; 160 161 /* 162 * help functions 163 */ 164 #ifndef max 165 #define max(a, b) ((a < b) ? b : a) 166 #endif 167 #ifndef min 168 #define min(a, b) ((a < b) ? a : b) 169 #endif 170 171 172 173 /* ------ Misc. ----------------- */ 174 175 extern int cmpSmiNodes(SmiNode *node1, SmiNode *node2); 176 177 178 179 /* ------ Graph primitives ------ */ 180 181 extern GraphNode *graphInsertNode(Graph *graph, SmiNode *smiNode); 182 183 extern GraphComponent *graphInsertComponent(Graph *graph); 184 185 extern void graphExit(Graph *graph); 186 187 extern GraphEdge *graphGetFirstEdgeByNode(Graph *graph, GraphNode *node); 188 189 extern GraphEdge *graphGetNextEdgeByNode(Graph *graph, 190 GraphEdge *edge, 191 GraphNode *node); 192 193 extern void graphShowNodes(Graph *graph); 194 195 196 197 /* ------ algorithm primitives ------ */ 198 199 extern int algGetNumberOfGroups(); 200 201 extern char *algGetTypeDescription(SmiNode *smiNode); 202 203 extern char *algGetTypeName(SmiNode *smiNode); 204 205 extern SmiModule *algGetTypeModule(SmiNode *smiNode); 206 207 extern int isBaseType(SmiNode *node); 208 209 extern int algIsIndexElement(SmiNode *table, SmiNode *node); 210 211 212 213 /* -------------- main functions ------------------------------------------- */ 214 215 extern void algLinkTables(); 216 217 extern void algCheckLinksByName(); 218 219 extern void algConnectLonelyNodes(); 220 221 extern void algCheckForDependency(); 222 223 extern void algCheckForPointerRels(); 224 225 #endif 226 227