blob: a9a7e2f727e8b343e7a2ba37f5254b6ccff38129 [file] [log] [blame]
Carmelo Casconeab5d41e2019-03-06 18:02:34 -08001/*
2 * Copyright 2019-present Open Networking Foundation
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 */
16
17package org.onosproject.drivers.stratum;
18
19import org.onosproject.net.driver.AbstractHandlerBehaviour;
20import org.onosproject.net.driver.DriverData;
21import org.onosproject.net.driver.DriverHandler;
22import org.onosproject.net.driver.HandlerBehaviour;
23
24/**
25 * Abstract implementation of a driver behaviour for Stratum devices that
26 * provides access to protocol-specific implementations of the same behavior.
27 *
28 * @param <B> type of behaviour
29 */
30public abstract class AbstractStratumBehaviour<B extends HandlerBehaviour>
31 extends AbstractHandlerBehaviour {
32
33 protected B p4runtime;
34 protected B gnmi;
oleksandr.yashchuk@plvision.eu3dbcaaf2019-03-13 14:44:46 +020035 protected B gnoi;
Carmelo Casconeab5d41e2019-03-06 18:02:34 -080036
oleksandr.yashchuk@plvision.eu3dbcaaf2019-03-13 14:44:46 +020037 public AbstractStratumBehaviour(B p4runtime, B gnmi, B gnoi) {
Carmelo Casconeab5d41e2019-03-06 18:02:34 -080038 this.p4runtime = p4runtime;
39 this.gnmi = gnmi;
oleksandr.yashchuk@plvision.eu3dbcaaf2019-03-13 14:44:46 +020040 this.gnoi = gnoi;
Carmelo Casconeab5d41e2019-03-06 18:02:34 -080041 }
42
43 @Override
44 public void setHandler(DriverHandler handler) {
45 super.setHandler(handler);
46 p4runtime.setHandler(handler);
47 gnmi.setHandler(handler);
oleksandr.yashchuk@plvision.eu3dbcaaf2019-03-13 14:44:46 +020048 gnoi.setHandler(handler);
Carmelo Casconeab5d41e2019-03-06 18:02:34 -080049 }
50
51 @Override
52 public void setData(DriverData data) {
53 super.setData(data);
54 p4runtime.setData(data);
55 gnmi.setData(data);
oleksandr.yashchuk@plvision.eu3dbcaaf2019-03-13 14:44:46 +020056 gnoi.setData(data);
Carmelo Casconeab5d41e2019-03-06 18:02:34 -080057 }
58}