Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
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 | |
| 18 | import org.onosproject.net.Annotations; |
| 19 | |
Andrea Campanella | 80520b8 | 2016-01-05 17:55:29 -0800 | [diff] [blame] | 20 | import java.util.List; |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 21 | import java.util.Map; |
| 22 | import java.util.Set; |
| 23 | |
| 24 | /** |
| 25 | * Representation of a specific family of device drivers. Behaviour configuration |
| 26 | * data is stored using {@link org.onosproject.net.Annotations}. |
| 27 | */ |
| 28 | public interface Driver extends Annotations { |
| 29 | |
| 30 | /** |
| 31 | * Returns the driver name. This is expected to be a reverse-DNS, |
| 32 | * Java package-like name. |
| 33 | * |
| 34 | * @return driver name |
| 35 | */ |
| 36 | String name(); |
| 37 | |
| 38 | /** |
Thomas Vachuska | 635c2d7 | 2015-05-08 14:32:13 -0700 | [diff] [blame] | 39 | * Returns the parent driver from which this driver inherits behaviours |
| 40 | * and properties. |
| 41 | * |
| 42 | * @return parent driver; null if driver has no parent |
Ray Milkey | ea12532 | 2016-02-16 13:35:09 -0800 | [diff] [blame] | 43 | * @deprecated 1.5.0 Falcon Release |
Thomas Vachuska | 635c2d7 | 2015-05-08 14:32:13 -0700 | [diff] [blame] | 44 | */ |
Andrea Campanella | 80520b8 | 2016-01-05 17:55:29 -0800 | [diff] [blame] | 45 | @Deprecated |
Thomas Vachuska | 635c2d7 | 2015-05-08 14:32:13 -0700 | [diff] [blame] | 46 | Driver parent(); |
| 47 | |
| 48 | /** |
Andrea Campanella | 80520b8 | 2016-01-05 17:55:29 -0800 | [diff] [blame] | 49 | * Returns all the parent drivers from which this driver inherits behaviours |
| 50 | * and properties. |
| 51 | * |
| 52 | * @return list of parent drivers; null if driver has no parent |
| 53 | */ |
| 54 | List<Driver> parents(); |
| 55 | |
| 56 | /** |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 57 | * Returns the device manufacturer name. |
| 58 | * |
| 59 | * @return manufacturer name |
| 60 | */ |
| 61 | String manufacturer(); |
| 62 | |
| 63 | /** |
| 64 | * Returns the device hardware version. |
| 65 | * |
| 66 | * @return hardware version |
| 67 | */ |
| 68 | String hwVersion(); |
| 69 | |
| 70 | /** |
| 71 | * Returns the device software version. |
| 72 | * |
| 73 | * @return software version |
| 74 | */ |
| 75 | String swVersion(); |
| 76 | |
| 77 | /** |
| 78 | * Returns the set of behaviours supported by this driver. |
Thomas Vachuska | 635c2d7 | 2015-05-08 14:32:13 -0700 | [diff] [blame] | 79 | * It reflects behaviours of only this driver and not its parent. |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 80 | * |
| 81 | * @return set of device driver behaviours |
| 82 | */ |
| 83 | Set<Class<? extends Behaviour>> behaviours(); |
| 84 | |
| 85 | /** |
Thomas Vachuska | 5c2f813 | 2015-04-08 23:09:08 -0700 | [diff] [blame] | 86 | * Returns the implementation class for the specified behaviour. |
Thomas Vachuska | 635c2d7 | 2015-05-08 14:32:13 -0700 | [diff] [blame] | 87 | * It reflects behaviours of only this driver and not its parent. |
Thomas Vachuska | 5c2f813 | 2015-04-08 23:09:08 -0700 | [diff] [blame] | 88 | * |
| 89 | * @param behaviour behaviour interface |
| 90 | * @return implementation class |
| 91 | */ |
| 92 | Class<? extends Behaviour> implementation(Class<? extends Behaviour> behaviour); |
| 93 | |
| 94 | /** |
Thomas Vachuska | 635c2d7 | 2015-05-08 14:32:13 -0700 | [diff] [blame] | 95 | * Indicates whether or not the driver, or any of its parents, support |
HIGUCHI Yuta | 82b3c11 | 2016-01-07 22:22:26 -0800 | [diff] [blame] | 96 | * the specified class of behaviour. |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 97 | * |
| 98 | * @param behaviourClass behaviour class |
| 99 | * @return true if behaviour is supported |
| 100 | */ |
| 101 | boolean hasBehaviour(Class<? extends Behaviour> behaviourClass); |
| 102 | |
| 103 | /** |
| 104 | * Creates an instance of behaviour primed with the specified driver data. |
Thomas Vachuska | 635c2d7 | 2015-05-08 14:32:13 -0700 | [diff] [blame] | 105 | * If the current driver does not support the specified behaviour and the |
| 106 | * driver has parent, the request is delegated to the parent driver. |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 107 | * |
| 108 | * @param data driver data context |
| 109 | * @param behaviourClass driver behaviour class |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 110 | * @param <T> type of behaviour |
| 111 | * @return behaviour instance |
| 112 | */ |
Thomas Vachuska | facc3f5 | 2015-04-10 08:58:36 -0700 | [diff] [blame] | 113 | <T extends Behaviour> T createBehaviour(DriverData data, Class<T> behaviourClass); |
| 114 | |
| 115 | /** |
Thomas Vachuska | f133bb1 | 2016-03-31 08:54:49 -0700 | [diff] [blame] | 116 | * Creates an instance of behaviour primed with the specified driver handler. |
Thomas Vachuska | 635c2d7 | 2015-05-08 14:32:13 -0700 | [diff] [blame] | 117 | * If the current driver does not support the specified behaviour and the |
| 118 | * driver has parent, the request is delegated to the parent driver. |
Thomas Vachuska | facc3f5 | 2015-04-10 08:58:36 -0700 | [diff] [blame] | 119 | * |
| 120 | * @param handler driver handler context |
| 121 | * @param behaviourClass driver behaviour class |
| 122 | * @param <T> type of behaviour |
| 123 | * @return behaviour instance |
| 124 | */ |
| 125 | <T extends Behaviour> T createBehaviour(DriverHandler handler, Class<T> behaviourClass); |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 126 | |
| 127 | /** |
| 128 | * Returns the set of annotations as map of key/value properties. |
| 129 | * |
| 130 | * @return map of properties |
| 131 | */ |
| 132 | Map<String, String> properties(); |
| 133 | |
Thomas Vachuska | 5c2f813 | 2015-04-08 23:09:08 -0700 | [diff] [blame] | 134 | /** |
| 135 | * Merges the specified driver behaviours and properties into this one, |
| 136 | * giving preference to the other driver when dealing with conflicts. |
| 137 | * |
| 138 | * @param other other driver |
| 139 | * @return merged driver |
| 140 | */ |
| 141 | Driver merge(Driver other); |
| 142 | |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 143 | } |