blob: 282ee034044cd92796cd8ccb390a15c3d0c2a4ec [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
Ray Milkeyea125322016-02-16 13:35:09 -080043 * @deprecated 1.5.0 Falcon Release
Thomas Vachuska635c2d72015-05-08 14:32:13 -070044 */
Andrea Campanella80520b82016-01-05 17:55:29 -080045 @Deprecated
Thomas Vachuska635c2d72015-05-08 14:32:13 -070046 Driver parent();
47
48 /**
Andrea Campanella80520b82016-01-05 17:55:29 -080049 * 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 Vachuskaa8f4e7d2015-01-08 17:31:55 -080057 * 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 Vachuska635c2d72015-05-08 14:32:13 -070079 * It reflects behaviours of only this driver and not its parent.
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -080080 *
81 * @return set of device driver behaviours
82 */
83 Set<Class<? extends Behaviour>> behaviours();
84
85 /**
Thomas Vachuska5c2f8132015-04-08 23:09:08 -070086 * Returns the implementation class for the specified behaviour.
Thomas Vachuska635c2d72015-05-08 14:32:13 -070087 * It reflects behaviours of only this driver and not its parent.
Thomas Vachuska5c2f8132015-04-08 23:09:08 -070088 *
89 * @param behaviour behaviour interface
90 * @return implementation class
91 */
92 Class<? extends Behaviour> implementation(Class<? extends Behaviour> behaviour);
93
94 /**
Thomas Vachuska635c2d72015-05-08 14:32:13 -070095 * Indicates whether or not the driver, or any of its parents, support
HIGUCHI Yuta82b3c112016-01-07 22:22:26 -080096 * the specified class of behaviour.
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -080097 *
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 Vachuska635c2d72015-05-08 14:32:13 -0700105 * 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 Vachuskaa8f4e7d2015-01-08 17:31:55 -0800107 *
108 * @param data driver data context
109 * @param behaviourClass driver behaviour class
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -0800110 * @param <T> type of behaviour
111 * @return behaviour instance
112 */
Thomas Vachuskafacc3f52015-04-10 08:58:36 -0700113 <T extends Behaviour> T createBehaviour(DriverData data, Class<T> behaviourClass);
114
115 /**
Thomas Vachuskaf133bb12016-03-31 08:54:49 -0700116 * Creates an instance of behaviour primed with the specified driver handler.
Thomas Vachuska635c2d72015-05-08 14:32:13 -0700117 * 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 Vachuskafacc3f52015-04-10 08:58:36 -0700119 *
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 Vachuskaa8f4e7d2015-01-08 17:31:55 -0800126
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 Vachuska5c2f8132015-04-08 23:09:08 -0700134 /**
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 Vachuskaa8f4e7d2015-01-08 17:31:55 -0800143}