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 | /** |
| 38 | * Returns the device manufacturer name. |
| 39 | * |
| 40 | * @return manufacturer name |
| 41 | */ |
| 42 | String manufacturer(); |
| 43 | |
| 44 | /** |
| 45 | * Returns the device hardware version. |
| 46 | * |
| 47 | * @return hardware version |
| 48 | */ |
| 49 | String hwVersion(); |
| 50 | |
| 51 | /** |
| 52 | * Returns the device software version. |
| 53 | * |
| 54 | * @return software version |
| 55 | */ |
| 56 | String swVersion(); |
| 57 | |
| 58 | /** |
| 59 | * Returns the set of behaviours supported by this driver. |
| 60 | * |
| 61 | * @return set of device driver behaviours |
| 62 | */ |
| 63 | Set<Class<? extends Behaviour>> behaviours(); |
| 64 | |
| 65 | /** |
Thomas Vachuska | 5c2f813 | 2015-04-08 23:09:08 -0700 | [diff] [blame^] | 66 | * Returns the implementation class for the specified behaviour. |
| 67 | * |
| 68 | * @param behaviour behaviour interface |
| 69 | * @return implementation class |
| 70 | */ |
| 71 | Class<? extends Behaviour> implementation(Class<? extends Behaviour> behaviour); |
| 72 | |
| 73 | /** |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 74 | * Indicates whether or not the driver supports the specified class |
| 75 | * of behaviour. |
| 76 | * |
| 77 | * @param behaviourClass behaviour class |
| 78 | * @return true if behaviour is supported |
| 79 | */ |
| 80 | boolean hasBehaviour(Class<? extends Behaviour> behaviourClass); |
| 81 | |
| 82 | /** |
| 83 | * Creates an instance of behaviour primed with the specified driver data. |
| 84 | * |
| 85 | * @param data driver data context |
| 86 | * @param behaviourClass driver behaviour class |
| 87 | * @param handler indicates behaviour is intended for handler context |
| 88 | * @param <T> type of behaviour |
| 89 | * @return behaviour instance |
| 90 | */ |
| 91 | <T extends Behaviour> T createBehaviour(DriverData data, Class<T> behaviourClass, |
| 92 | boolean handler); |
| 93 | |
| 94 | /** |
| 95 | * Returns the set of annotations as map of key/value properties. |
| 96 | * |
| 97 | * @return map of properties |
| 98 | */ |
| 99 | Map<String, String> properties(); |
| 100 | |
Thomas Vachuska | 5c2f813 | 2015-04-08 23:09:08 -0700 | [diff] [blame^] | 101 | /** |
| 102 | * Merges the specified driver behaviours and properties into this one, |
| 103 | * giving preference to the other driver when dealing with conflicts. |
| 104 | * |
| 105 | * @param other other driver |
| 106 | * @return merged driver |
| 107 | */ |
| 108 | Driver merge(Driver other); |
| 109 | |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 110 | } |