blob: 824845aac10abe11771e887cdc9487f7121895c4 [file] [log] [blame]
Simon Hunt22c35df2017-04-26 17:28:42 -07001/*
2 * Copyright 2017-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
18package org.onosproject.ui;
19
20import org.slf4j.Logger;
21import org.slf4j.LoggerFactory;
22
23/**
24 * Represents a user interface topology-2 view overlay.
25 * <p>
Simon Hunt6cc86452017-04-27 17:46:22 -070026 * This base class does little more than provide a logger and an identifier.
27 * <p>
28 * Subclasses will want to override some or all of the base methods
Simon Hunt22c35df2017-04-26 17:28:42 -070029 * to do useful things during the life-cycle of the (topo-2) overlay.
30 */
31public class UiTopo2Overlay {
32
Simon Hunt22c35df2017-04-26 17:28:42 -070033 protected final Logger log = LoggerFactory.getLogger(getClass());
34
35 private final String id;
Simon Hunt22c35df2017-04-26 17:28:42 -070036
37 private boolean isActive = false;
38
39 /**
Simon Hunt6cc86452017-04-27 17:46:22 -070040 * Creates a new user interface topology view overlay descriptor with
41 * the given identifier.
Simon Hunt22c35df2017-04-26 17:28:42 -070042 *
43 * @param id overlay identifier
Simon Hunt22c35df2017-04-26 17:28:42 -070044 */
Simon Hunt6cc86452017-04-27 17:46:22 -070045 public UiTopo2Overlay(String id) {
Simon Hunt22c35df2017-04-26 17:28:42 -070046 this.id = id;
Simon Hunt22c35df2017-04-26 17:28:42 -070047 }
48
49 /**
50 * Returns the identifier for this overlay.
51 *
52 * @return the identifier
53 */
54 public String id() {
55 return id;
56 }
57
Simon Hunt6cc86452017-04-27 17:46:22 -070058 @Override
59 public String toString() {
60 return "UiTopo2Overlay{id=\"" + id +
61 "\", class=\"" + getClass().getSimpleName() + "\"}";
Simon Hunt22c35df2017-04-26 17:28:42 -070062 }
63
64 /**
65 * Callback invoked to initialize this overlay, soon after creation.
66 * This default implementation does nothing.
Simon Hunt6cc86452017-04-27 17:46:22 -070067 * Subclasses may choose to override this to set some initial state.
Simon Hunt22c35df2017-04-26 17:28:42 -070068 */
69 public void init() {
70 }
71
72 /**
73 * Callback invoked when this overlay is activated.
74 */
75 public void activate() {
76 isActive = true;
77 }
78
79 /**
80 * Callback invoked when this overlay is deactivated.
81 */
82 public void deactivate() {
83 isActive = false;
84 }
85
86 /**
87 * Returns true if this overlay is currently active.
88 *
89 * @return true if overlay active
90 */
91 public boolean isActive() {
92 return isActive;
93 }
94
95 /**
96 * Callback invoked to destroy this instance by cleaning up any
97 * internal state ready for garbage collection.
98 * This default implementation holds no state and does nothing.
99 */
100 public void destroy() {
101 }
102
103 /**
104 * Callback invoked when the topology highlighting should be updated.
105 * It is the implementation's responsibility to update the Model
106 * Highlighter state. This implementation does nothing.
107 */
108 public void highlightingCallback(/* ref to highlight model ? */) {
109
110 }
111}