blob: d72ff3d1fce52947458dca69ce20d09e1eb8d11f [file] [log] [blame]
Simon Huntcda9c032016-04-11 10:32:54 -07001/*
2 * Copyright 2016 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
17package org.onosproject.ui.impl.topo.model;
18
19import org.onosproject.event.EventDispatcher;
20import org.onosproject.net.Device;
21import org.onosproject.ui.model.topo.UiDevice;
22
23/**
24 * UI Topology Model cache.
25 */
26class ModelCache {
27
28 private final EventDispatcher dispatcher;
29
30 ModelCache(EventDispatcher eventDispatcher) {
31 this.dispatcher = eventDispatcher;
32 }
33
34 /**
35 * Clear our model.
36 */
37 void clear() {
38 // TODO: clear our internal state
39 }
40
41 /**
42 * Create our internal model of the global topology.
43 */
44 void load() {
45// loadClusterMembers();
46// loadRegions();
47// loadDevices();
48// loadHosts();
49// loadLinks();
50 }
51
52
53 // add or update device
54 void addOrUpdateDevice(Device device) {
55 // fetch UiDevice
56 UiDevice uiDevice = new UiDevice();
57
58 dispatcher.post(
59 new UiModelEvent(UiModelEvent.Type.DEVICE_ADDED, uiDevice)
60 );
61
62 }
63
64 void removeDevice(Device device) {
65 UiDevice uiDevice = new UiDevice();
66
67 dispatcher.post(
68 new UiModelEvent(UiModelEvent.Type.DEVICE_REMOVED, uiDevice)
69 );
70
71 }
72
73 // TODO remaining model objects
74
75}