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