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