blob: 8c13f362d862840c9ad2427deab9403c98d76764 [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 /**
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 Vachuska5c2f8132015-04-08 23:09:08 -070066 * 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 Vachuskaa8f4e7d2015-01-08 17:31:55 -080074 * 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
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -080087 * @param <T> type of behaviour
88 * @return behaviour instance
89 */
Thomas Vachuskafacc3f52015-04-10 08:58:36 -070090 <T extends Behaviour> T createBehaviour(DriverData data, Class<T> behaviourClass);
91
92 /**
93 * Creates an instance of behaviour primed with the specified driver data.
94 *
95 * @param handler driver handler context
96 * @param behaviourClass driver behaviour class
97 * @param <T> type of behaviour
98 * @return behaviour instance
99 */
100 <T extends Behaviour> T createBehaviour(DriverHandler handler, Class<T> behaviourClass);
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -0800101
102 /**
103 * Returns the set of annotations as map of key/value properties.
104 *
105 * @return map of properties
106 */
107 Map<String, String> properties();
108
Thomas Vachuska5c2f8132015-04-08 23:09:08 -0700109 /**
110 * Merges the specified driver behaviours and properties into this one,
111 * giving preference to the other driver when dealing with conflicts.
112 *
113 * @param other other driver
114 * @return merged driver
115 */
116 Driver merge(Driver other);
117
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -0800118}