blob: 7af83b41fb45ea7240e2e21003e627396b898ae9 [file] [log] [blame]
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -08003 *
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
Yuta HIGUCHI0083a512017-02-21 12:14:38 -080048 // TODO should revise behaviour to return empty List when driver has no parent
Thomas Vachuska635c2d72015-05-08 14:32:13 -070049 /**
Andrea Campanella80520b82016-01-05 17:55:29 -080050 * Returns all the parent drivers from which this driver inherits behaviours
51 * and properties.
52 *
53 * @return list of parent drivers; null if driver has no parent
54 */
55 List<Driver> parents();
56
57 /**
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -080058 * Returns the device manufacturer name.
59 *
60 * @return manufacturer name
61 */
62 String manufacturer();
63
64 /**
65 * Returns the device hardware version.
66 *
67 * @return hardware version
68 */
69 String hwVersion();
70
71 /**
72 * Returns the device software version.
73 *
74 * @return software version
75 */
76 String swVersion();
77
78 /**
79 * Returns the set of behaviours supported by this driver.
Thomas Vachuska635c2d72015-05-08 14:32:13 -070080 * It reflects behaviours of only this driver and not its parent.
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -080081 *
82 * @return set of device driver behaviours
83 */
84 Set<Class<? extends Behaviour>> behaviours();
85
86 /**
Thomas Vachuska5c2f8132015-04-08 23:09:08 -070087 * Returns the implementation class for the specified behaviour.
Thomas Vachuska635c2d72015-05-08 14:32:13 -070088 * It reflects behaviours of only this driver and not its parent.
Thomas Vachuska5c2f8132015-04-08 23:09:08 -070089 *
90 * @param behaviour behaviour interface
91 * @return implementation class
92 */
93 Class<? extends Behaviour> implementation(Class<? extends Behaviour> behaviour);
94
95 /**
Thomas Vachuska635c2d72015-05-08 14:32:13 -070096 * Indicates whether or not the driver, or any of its parents, support
HIGUCHI Yuta82b3c112016-01-07 22:22:26 -080097 * the specified class of behaviour.
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -080098 *
99 * @param behaviourClass behaviour class
100 * @return true if behaviour is supported
101 */
102 boolean hasBehaviour(Class<? extends Behaviour> behaviourClass);
103
104 /**
105 * Creates an instance of behaviour primed with the specified driver data.
Thomas Vachuska635c2d72015-05-08 14:32:13 -0700106 * 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 Vachuskaa8f4e7d2015-01-08 17:31:55 -0800108 *
109 * @param data driver data context
110 * @param behaviourClass driver behaviour class
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -0800111 * @param <T> type of behaviour
112 * @return behaviour instance
113 */
Thomas Vachuskafacc3f52015-04-10 08:58:36 -0700114 <T extends Behaviour> T createBehaviour(DriverData data, Class<T> behaviourClass);
115
116 /**
Thomas Vachuskaf133bb12016-03-31 08:54:49 -0700117 * Creates an instance of behaviour primed with the specified driver handler.
Thomas Vachuska635c2d72015-05-08 14:32:13 -0700118 * If the current driver does not support the specified behaviour and the
119 * driver has parent, the request is delegated to the parent driver.
Thomas Vachuskafacc3f52015-04-10 08:58:36 -0700120 *
121 * @param handler driver handler context
122 * @param behaviourClass driver behaviour class
123 * @param <T> type of behaviour
124 * @return behaviour instance
125 */
126 <T extends Behaviour> T createBehaviour(DriverHandler handler, Class<T> behaviourClass);
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -0800127
128 /**
129 * Returns the set of annotations as map of key/value properties.
130 *
131 * @return map of properties
132 */
133 Map<String, String> properties();
134
Thomas Vachuska5c2f8132015-04-08 23:09:08 -0700135 /**
136 * Merges the specified driver behaviours and properties into this one,
137 * giving preference to the other driver when dealing with conflicts.
138 *
139 * @param other other driver
140 * @return merged driver
141 */
142 Driver merge(Driver other);
143
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -0800144}