blob: 50611b14a2e3565a881eb0e5ed7da777764de727 [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
20import java.util.Map;
21import 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 */
27public 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 Vachuska635c2d72015-05-08 14:32:13 -070038 * 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 Vachuskaa8f4e7d2015-01-08 17:31:55 -080046 * 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 Vachuska635c2d72015-05-08 14:32:13 -070068 * It reflects behaviours of only this driver and not its parent.
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -080069 *
70 * @return set of device driver behaviours
71 */
72 Set<Class<? extends Behaviour>> behaviours();
73
74 /**
Thomas Vachuska5c2f8132015-04-08 23:09:08 -070075 * Returns the implementation class for the specified behaviour.
Thomas Vachuska635c2d72015-05-08 14:32:13 -070076 * It reflects behaviours of only this driver and not its parent.
Thomas Vachuska5c2f8132015-04-08 23:09:08 -070077 *
78 * @param behaviour behaviour interface
79 * @return implementation class
80 */
81 Class<? extends Behaviour> implementation(Class<? extends Behaviour> behaviour);
82
83 /**
Thomas Vachuska635c2d72015-05-08 14:32:13 -070084 * Indicates whether or not the driver, or any of its parents, support
85 * the specified class of behaviour. It
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -080086 *
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 Vachuska635c2d72015-05-08 14:32:13 -070094 * 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 Vachuskaa8f4e7d2015-01-08 17:31:55 -080096 *
97 * @param data driver data context
98 * @param behaviourClass driver behaviour class
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -080099 * @param <T> type of behaviour
100 * @return behaviour instance
101 */
Thomas Vachuskafacc3f52015-04-10 08:58:36 -0700102 <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 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 Vachuskafacc3f52015-04-10 08:58:36 -0700108 *
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 Vachuskaa8f4e7d2015-01-08 17:31:55 -0800115
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 Vachuska5c2f8132015-04-08 23:09:08 -0700123 /**
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 Vachuskaa8f4e7d2015-01-08 17:31:55 -0800132}