Carmelo Cascone | ab5d41e | 2019-03-06 18:02:34 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package org.onosproject.drivers.stratum; |
| 18 | |
| 19 | import org.onosproject.net.driver.AbstractHandlerBehaviour; |
| 20 | import org.onosproject.net.driver.DriverData; |
| 21 | import org.onosproject.net.driver.DriverHandler; |
| 22 | import 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 | */ |
| 30 | public abstract class AbstractStratumBehaviour<B extends HandlerBehaviour> |
| 31 | extends AbstractHandlerBehaviour { |
| 32 | |
| 33 | protected B p4runtime; |
| 34 | protected B gnmi; |
oleksandr.yashchuk@plvision.eu | 3dbcaaf | 2019-03-13 14:44:46 +0200 | [diff] [blame^] | 35 | protected B gnoi; |
Carmelo Cascone | ab5d41e | 2019-03-06 18:02:34 -0800 | [diff] [blame] | 36 | |
oleksandr.yashchuk@plvision.eu | 3dbcaaf | 2019-03-13 14:44:46 +0200 | [diff] [blame^] | 37 | public AbstractStratumBehaviour(B p4runtime, B gnmi, B gnoi) { |
Carmelo Cascone | ab5d41e | 2019-03-06 18:02:34 -0800 | [diff] [blame] | 38 | this.p4runtime = p4runtime; |
| 39 | this.gnmi = gnmi; |
oleksandr.yashchuk@plvision.eu | 3dbcaaf | 2019-03-13 14:44:46 +0200 | [diff] [blame^] | 40 | this.gnoi = gnoi; |
Carmelo Cascone | ab5d41e | 2019-03-06 18:02:34 -0800 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | @Override |
| 44 | public void setHandler(DriverHandler handler) { |
| 45 | super.setHandler(handler); |
| 46 | p4runtime.setHandler(handler); |
| 47 | gnmi.setHandler(handler); |
oleksandr.yashchuk@plvision.eu | 3dbcaaf | 2019-03-13 14:44:46 +0200 | [diff] [blame^] | 48 | gnoi.setHandler(handler); |
Carmelo Cascone | ab5d41e | 2019-03-06 18:02:34 -0800 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | @Override |
| 52 | public void setData(DriverData data) { |
| 53 | super.setData(data); |
| 54 | p4runtime.setData(data); |
| 55 | gnmi.setData(data); |
oleksandr.yashchuk@plvision.eu | 3dbcaaf | 2019-03-13 14:44:46 +0200 | [diff] [blame^] | 56 | gnoi.setData(data); |
Carmelo Cascone | ab5d41e | 2019-03-06 18:02:34 -0800 | [diff] [blame] | 57 | } |
| 58 | } |