Yuta HIGUCHI | b9af6b7 | 2016-06-10 10:52:58 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present 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 | */ |
| 16 | package org.onosproject.net.config; |
| 17 | |
| 18 | import org.onosproject.net.ConnectPoint; |
| 19 | import org.onosproject.net.DeviceId; |
| 20 | import org.onosproject.net.device.PortDescription; |
| 21 | |
| 22 | import com.google.common.annotations.Beta; |
| 23 | |
| 24 | /** |
| 25 | * {@link ConfigOperator} for Port. |
| 26 | * <p> |
| 27 | * Note: We currently assumes {@link PortConfigOperator}s are commutative. |
| 28 | */ |
| 29 | @Beta |
| 30 | public interface PortConfigOperator extends ConfigOperator { |
| 31 | |
| 32 | /** |
| 33 | * Binds {@link NetworkConfigService} to use for retrieving configuration. |
| 34 | * |
| 35 | * @param networkConfigService the service to use |
| 36 | */ |
| 37 | void bindService(NetworkConfigService networkConfigService); |
| 38 | |
| 39 | |
| 40 | /** |
| 41 | * Generates a PortDescription containing fields from a PortDescription and |
| 42 | * configuration. |
| 43 | * |
| 44 | * @param cp {@link ConnectPoint} representing the port. |
| 45 | * @param descr input {@link PortDescription} |
| 46 | * @return Combined {@link PortDescription} |
| 47 | */ |
| 48 | PortDescription combine(ConnectPoint cp, PortDescription descr); |
| 49 | |
| 50 | /** |
| 51 | * Generates a PortDescription containing fields from a PortDescription and |
| 52 | * configuration. |
| 53 | * |
| 54 | * @param did DeviceId which the port described by {@code descr} resides. |
| 55 | * @param descr input {@link PortDescription} |
| 56 | * @return Combined {@link PortDescription} |
| 57 | */ |
| 58 | default PortDescription combine(DeviceId did, PortDescription descr) { |
| 59 | return combine(new ConnectPoint(did, descr.portNumber()), descr); |
| 60 | } |
| 61 | |
| 62 | } |