Steven Burrows | 57e24e9 | 2016-08-04 18:38:24 +0100 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2016-present Open Networking Laboratory |
| 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 | */ |
| 16 | |
| 17 | /* |
| 18 | ONOS GUI -- Topology Force Module. |
| 19 | Visualization of the topology in an SVG layer, using a D3 Force Layout. |
| 20 | */ |
| 21 | |
| 22 | (function () { |
| 23 | 'use strict'; |
| 24 | |
| 25 | function Model(attributes) { |
| 26 | |
| 27 | var attrs = attributes || {}; |
| 28 | this.attributes = {}; |
| 29 | |
| 30 | attrs = angular.extend({}, attrs); |
| 31 | this.set(attrs); |
| 32 | } |
| 33 | |
| 34 | Model.prototype = { |
| 35 | |
| 36 | get: function (attr) { |
| 37 | return this.attributes[attr]; |
| 38 | }, |
| 39 | |
| 40 | set: function(data) { |
| 41 | angular.extend(this.attributes, data); |
| 42 | }, |
| 43 | }; |
| 44 | |
| 45 | |
| 46 | Model.extend = function (protoProps, staticProps) { |
| 47 | |
| 48 | var parent = this; |
| 49 | var child; |
| 50 | |
| 51 | child = function () { |
| 52 | return parent.apply(this, arguments); |
| 53 | }; |
| 54 | |
| 55 | angular.extend(child, parent, staticProps); |
| 56 | |
| 57 | // Set the prototype chain to inherit from `parent`, without calling |
| 58 | // `parent`'s constructor function and add the prototype properties. |
| 59 | child.prototype = angular.extend({}, parent.prototype, protoProps); |
| 60 | child.prototype.constructor = child; |
| 61 | |
| 62 | // Set a convenience property in case the parent's prototype is needed |
| 63 | // later. |
| 64 | child.__super__ = parent.prototype; |
| 65 | |
| 66 | return child; |
| 67 | }; |
| 68 | |
| 69 | angular.module('ovTopo2') |
| 70 | .factory('Topo2Model', |
| 71 | [ |
| 72 | function () { |
| 73 | return Model; |
| 74 | } |
| 75 | ]); |
| 76 | |
| 77 | })(); |