blob: 6ac7a7a2da4db30faa3fa1173b847520935640ea [file] [log] [blame]
alshabibfaa1e362015-04-02 15:01:54 -07001/*
2 * Copyright 2015 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 */
16package org.onosproject.net.flowobjective;
17
Thomas Vachuskaa9d491e2015-05-20 11:17:21 -070018import com.google.common.annotations.Beta;
alshabibfaa1e362015-04-02 15:01:54 -070019import org.onosproject.core.ApplicationId;
20
alshabib2a441c62015-04-13 18:39:38 -070021import java.util.Optional;
22
alshabibfaa1e362015-04-02 15:01:54 -070023/**
24 * Base representation of an flow description.
25 */
Thomas Vachuskaa9d491e2015-05-20 11:17:21 -070026@Beta
alshabibfaa1e362015-04-02 15:01:54 -070027public interface Objective {
28
Sho SHIMIZUe2952e42015-09-11 17:11:21 -070029 boolean DEFAULT_PERMANENT = true;
30 int DEFAULT_TIMEOUT = 0;
31 int DEFAULT_PRIORITY = 32768;
alshabibfaa1e362015-04-02 15:01:54 -070032
33 /**
34 * Type of operation.
35 */
36 enum Operation {
37 /**
38 * Adds the objective.
39 */
40 ADD,
41
42 /**
43 * Removes the objective.
44 */
45 REMOVE
46 }
47
48 /**
49 * An identifier for this objective.
50 *
51 * @return an integer
52 */
53 int id();
54
55 /**
56 * The priority for this objective.
57 *
58 * @return an integer
59 */
60 int priority();
61
62 /**
63 * The application which applied this objective.
64 *
65 * @return an application id
66 */
67 ApplicationId appId();
68
69 /**
70 * The timeout for this objective.
71 *
72 * @return an integer
73 */
74 int timeout();
75
76 /**
77 * Whether this objective is permanent.
78 *
79 * @return a boolean
80 */
81 boolean permanent();
82
83 /**
84 * The type of operation for this objective.
85 *
86 * @return an operation
87 */
88 Operation op();
89
90 /**
alshabib2a441c62015-04-13 18:39:38 -070091 * Obtains an optional context.
92 *
93 * @return optional; which will be empty if there is no context.
94 * Otherwise it will return the context.
95 */
96 Optional<ObjectiveContext> context();
97
98 /**
alshabibfaa1e362015-04-02 15:01:54 -070099 * An objective builder.
100 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700101 interface Builder {
alshabibfaa1e362015-04-02 15:01:54 -0700102 /**
103 * Makes the filtering objective temporary.
104 *
105 * @param timeout a timeout
106 * @return an objective builder
107 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700108 Builder makeTemporary(int timeout);
alshabibfaa1e362015-04-02 15:01:54 -0700109
110 /**
111 * Makes the filtering objective permanent.
112 *
113 * @return an objective builder
114 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700115 Builder makePermanent();
alshabibfaa1e362015-04-02 15:01:54 -0700116
117 /**
118 * Specifies the application which applied the filter.
119 *
120 * @param appId an application id
121 * @return an objective builder
122 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700123 Builder fromApp(ApplicationId appId);
alshabibfaa1e362015-04-02 15:01:54 -0700124
125 /**
126 * Sets the priority for this objective.
127 *
128 * @param priority an integer
129 * @return an objective builder
130 */
Sho SHIMIZU3310a342015-05-13 12:14:05 -0700131 Builder withPriority(int priority);
alshabibfaa1e362015-04-02 15:01:54 -0700132 }
133
134}