blob: aac465b1a15df4dfee38182fab1e6d2929281b70 [file] [log] [blame]
Lee Yongjae7c27bb42017-11-17 12:00:45 +09001/*
Jian Lic7efc1d2018-08-23 16:37:34 +09002 * Copyright 2018-present Open Networking Foundation
Lee Yongjae7c27bb42017-11-17 12:00:45 +09003 *
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
Jian Lic7efc1d2018-08-23 16:37:34 +090017package org.onosproject.simplefabric.api;
Lee Yongjae7c27bb42017-11-17 12:00:45 +090018
19import org.onosproject.event.AbstractEvent;
20
21import java.io.OutputStream;
22import java.io.PrintStream;
23
24/**
25 * Describes an interface event.
26 */
27public class SimpleFabricEvent extends AbstractEvent<SimpleFabricEvent.Type, String> {
28
29 public enum Type {
30 SIMPLE_FABRIC_UPDATED, /* Indicates topology info has been updated. */
31 SIMPLE_FABRIC_FLUSH, /* Indicates flush triggered. */
32 SIMPLE_FABRIC_IDLE, /* Indicates idle check. */
33 SIMPLE_FABRIC_DUMP /* Indicates to dump info on the subject to output stream. */
34 }
35
36 private PrintStream printStream; // output stream for SIMPLE_FABRIC_DUMP
37
38 /**
39 * Creates an interface event with type and subject.
40 *
41 * @param type event type
42 * @param subject subject for dump event or dummy
43 */
44 public SimpleFabricEvent(Type type, String subject) {
45 super(type, subject); /* subject is dummy */
46 }
47
48 /**
49 * Creates an interface event with type, subject and output stream for dump.
50 *
51 * @param type event type
52 * @param subject subject for dump event
53 * @param out output stream to dump out
54 */
55 public SimpleFabricEvent(Type type, String subject, OutputStream out) {
56 super(type, subject); /* subject is dummy */
57 printStream = new PrintStream(out, true);
58 }
59
60 public PrintStream out() {
61 return printStream;
62 }
63
64}
65