Hyunsun Moon | f4ba44f | 2017-03-14 03:25:52 +0900 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame^] | 2 | * Copyright 2017-present Open Networking Foundation |
Hyunsun Moon | f4ba44f | 2017-03-14 03:25:52 +0900 | [diff] [blame] | 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.ofagent.api; |
| 17 | |
| 18 | import org.onosproject.event.AbstractEvent; |
| 19 | |
| 20 | /** |
| 21 | * Describes OFAgent event. |
| 22 | */ |
| 23 | public class OFAgentEvent extends AbstractEvent<OFAgentEvent.Type, OFAgent> { |
| 24 | |
| 25 | private final OFController controller; |
| 26 | |
| 27 | public enum Type { |
| 28 | |
| 29 | /** |
| 30 | * Signifies that a new OFAgent is created. |
| 31 | */ |
| 32 | OFAGENT_CREATED, |
| 33 | |
| 34 | /** |
| 35 | * Signifies that the OFAgent is removed. |
| 36 | */ |
| 37 | OFAGENT_REMOVED, |
| 38 | |
| 39 | /** |
| 40 | * Signifies that the new external controller is added. |
| 41 | */ |
| 42 | OFAGENT_CONTROLLER_ADDED, |
| 43 | |
| 44 | /** |
| 45 | * Signifies that the external controller is removed. |
| 46 | */ |
| 47 | OFAGENT_CONTROLLER_REMOVED, |
| 48 | |
| 49 | /** |
| 50 | * Signifies that the OFAgent is started. |
| 51 | */ |
| 52 | OFAGENT_STARTED, |
| 53 | |
| 54 | /** |
| 55 | * Signifies that the OFAgent is stopped. |
| 56 | */ |
| 57 | OFAGENT_STOPPED, |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Creates an event of a given type for the specified ofagent and the current time. |
| 62 | * |
| 63 | * @param type ofagent event type |
| 64 | * @param ofAgent ofagent instance |
| 65 | */ |
| 66 | public OFAgentEvent(OFAgentEvent.Type type, OFAgent ofAgent) { |
| 67 | super(type, ofAgent); |
| 68 | this.controller = null; |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Creates an event of a given type for the specified ofagent and the updated controller. |
| 73 | * |
| 74 | * @param type ofagent event type |
| 75 | * @param ofAgent ofagent instance |
| 76 | * @param controller updated external controller |
| 77 | */ |
| 78 | public OFAgentEvent(OFAgentEvent.Type type, OFAgent ofAgent, OFController controller) { |
| 79 | super(type, ofAgent); |
| 80 | this.controller = controller; |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Returns the updated controller. |
| 85 | * |
| 86 | * @return updated controller; null if the event is not controller related |
| 87 | */ |
| 88 | public OFController controller() { |
| 89 | return this.controller; |
| 90 | } |
| 91 | } |