blob: e4d7768edcbb369117c2c4061cbd3c95dec4f15c [file] [log] [blame]
Sean Condon0c577f62018-11-18 22:40:05 +00001/*
2 * Copyright 2018-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the 'License');
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an 'AS IS' BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16import { Node } from './node';
17import * as d3 from 'd3';
18
19export enum LinkType {
20 UiRegionLink,
21 UiDeviceLink,
22 UiEdgeLink
23}
24
25/**
26 * model of the topo2CurrentRegion region rollup from Region below
27 *
28 */
29export interface RegionRollup {
30 id: string;
31 epA: string;
32 epB: string;
33 portA: string;
34 portB: string;
35 type: LinkType;
36}
37
38/**
39 * Implementing SimulationLinkDatum interface into our custom Link class
40 */
41export class Link implements d3.SimulationLinkDatum<Node> {
42 // Optional - defining optional implementation properties - required for relevant typing assistance
43 index?: number;
44
45 // Must - defining enforced implementation properties
46 source: Node;
47 target: Node;
48
49 constructor(source, target) {
50 this.source = source;
51 this.target = target;
52 }
53}
54
55/**
56 * model of the topo2CurrentRegion region link from Region below
57 */
58export class RegionLink extends Link {
59 id: string; // The id of the link in the format epA/portA~epB/portB
60 epA: string; // The name of the device or host at one end
61 epB: string; // The name of the device or host at the other end
62 portA: string; // The number of the port at one end
63 portB: string; // The number of the port at the other end
64 rollup: RegionRollup[]; // Links in sub regions represented by this one link
65 type: LinkType;
66
67 constructor(type: LinkType, nodeA: Node, nodeB: Node) {
68 super(nodeA, nodeB);
69 }
70}