blob: afb6ae6a1ea482ab65085e48aacca52a1992e864 [file] [log] [blame]
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -08001/*
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 */
16package org.onosproject.net.driver;
17
18import org.onosproject.net.Annotations;
19
Andrea Campanella80520b82016-01-05 17:55:29 -080020import java.util.List;
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -080021import java.util.Map;
22import 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 */
28public 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 Vachuska635c2d72015-05-08 14:32:13 -070039 * 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 Campanella80520b82016-01-05 17:55:29 -080044 @Deprecated
Thomas Vachuska635c2d72015-05-08 14:32:13 -070045 Driver parent();
46
47 /**
Andrea Campanella80520b82016-01-05 17:55:29 -080048 * 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 Vachuskaa8f4e7d2015-01-08 17:31:55 -080056 * 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 Vachuska635c2d72015-05-08 14:32:13 -070078 * It reflects behaviours of only this driver and not its parent.
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -080079 *
80 * @return set of device driver behaviours
81 */
82 Set<Class<? extends Behaviour>> behaviours();
83
84 /**
Thomas Vachuska5c2f8132015-04-08 23:09:08 -070085 * Returns the implementation class for the specified behaviour.
Thomas Vachuska635c2d72015-05-08 14:32:13 -070086 * It reflects behaviours of only this driver and not its parent.
Thomas Vachuska5c2f8132015-04-08 23:09:08 -070087 *
88 * @param behaviour behaviour interface
89 * @return implementation class
90 */
91 Class<? extends Behaviour> implementation(Class<? extends Behaviour> behaviour);
92
93 /**
Thomas Vachuska635c2d72015-05-08 14:32:13 -070094 * Indicates whether or not the driver, or any of its parents, support
HIGUCHI Yuta82b3c112016-01-07 22:22:26 -080095 * the specified class of behaviour.
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -080096 *
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 Vachuska635c2d72015-05-08 14:32:13 -0700104 * 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 Vachuskaa8f4e7d2015-01-08 17:31:55 -0800106 *
107 * @param data driver data context
108 * @param behaviourClass driver behaviour class
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -0800109 * @param <T> type of behaviour
110 * @return behaviour instance
111 */
Thomas Vachuskafacc3f52015-04-10 08:58:36 -0700112 <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 Vachuska635c2d72015-05-08 14:32:13 -0700116 * 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 Vachuskafacc3f52015-04-10 08:58:36 -0700118 *
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 Vachuskaa8f4e7d2015-01-08 17:31:55 -0800125
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 Vachuska5c2f8132015-04-08 23:09:08 -0700133 /**
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 Vachuskaa8f4e7d2015-01-08 17:31:55 -0800142}