Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 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 | package org.onosproject.net.driver; |
| 17 | |
Thomas Vachuska | 80b0a80 | 2015-07-17 08:43:30 -0700 | [diff] [blame] | 18 | import org.onosproject.net.DeviceId; |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 19 | import org.onosproject.net.MutableAnnotations; |
| 20 | |
| 21 | /** |
Thomas Vachuska | 3afbc7f | 2016-02-01 15:55:38 -0800 | [diff] [blame] | 22 | * Container for data about an entity, e.g. device, link. Data is stored using |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 23 | * {@link org.onosproject.net.MutableAnnotations}. |
Thomas Vachuska | 7b3fe3a | 2016-02-01 11:26:22 -0800 | [diff] [blame] | 24 | * |
| 25 | * Note that only derivatives of {@link HandlerBehaviour} can expect mutability |
| 26 | * from the backing driver data instance; other behaviours must rely on |
| 27 | * immutable {@link org.onosproject.net.Annotations} only. |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 28 | */ |
| 29 | public interface DriverData extends MutableAnnotations { |
| 30 | |
| 31 | /** |
| 32 | * Returns the parent device driver. |
| 33 | * |
| 34 | * @return device driver |
| 35 | */ |
Thomas Vachuska | ca88bb7 | 2015-04-08 19:38:02 -0700 | [diff] [blame] | 36 | Driver driver(); |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 37 | |
| 38 | /** |
Thomas Vachuska | 80b0a80 | 2015-07-17 08:43:30 -0700 | [diff] [blame] | 39 | * Returns the device identifier. |
| 40 | * |
| 41 | * @return device identifier |
| 42 | */ |
| 43 | DeviceId deviceId(); |
| 44 | |
| 45 | /** |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 46 | * Returns the specified facet of behaviour to access the device data. |
| 47 | * |
Thomas Vachuska | 3afbc7f | 2016-02-01 15:55:38 -0800 | [diff] [blame] | 48 | * Implementations are expected to defer to the backing driver for creation |
| 49 | * of the requested behaviour. |
| 50 | * |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 51 | * @param behaviourClass behaviour class |
| 52 | * @param <T> type of behaviour |
| 53 | * @return requested behaviour or null if not supported |
| 54 | */ |
Thomas Vachuska | 3afbc7f | 2016-02-01 15:55:38 -0800 | [diff] [blame] | 55 | default <T extends Behaviour> T behaviour(Class<T> behaviourClass) { |
| 56 | return driver().createBehaviour(this, behaviourClass); |
| 57 | } |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 58 | |
| 59 | } |