2 * Copyright (c) 2016 Cisco and/or its affiliates.
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:
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package io.fd.honeycomb.translate.v3po.vppclassifier;
19 import com.google.common.base.Optional;
20 import io.fd.honeycomb.translate.MappingContext;
21 import javax.annotation.Nonnull;
22 import javax.annotation.Nullable;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev161214.VppNodeName;
26 * Manages metadata for vpp-classifier
28 public interface VppClassifierContextManager {
31 * Creates metadata for classify table.
33 * @param id classify table index
34 * @param name classify table name
35 * @param classifierNode name of VPP node the table is defined for
36 * @param ctx mapping context providing context data for current transaction
38 void addTable(final int id, @Nonnull final String name, @Nullable final VppNodeName classifierNode,
39 @Nonnull final MappingContext ctx);
42 * Check whether metadata for given classify table metadata is present.
44 * @param name classify table name
45 * @param ctx mapping context providing context data for current transaction
46 * @return true if present, false otherwise
48 boolean containsTable(@Nonnull String name, @Nonnull final MappingContext ctx);
51 * Returns classify table index associated with the given name.
53 * @param name classify table name
54 * @param ctx mapping context providing context data for current transaction
55 * @return integer index value matching supplied classify table name
56 * @throws IllegalArgumentException if classify table was not found
58 int getTableIndex(@Nonnull final String name, @Nonnull final MappingContext ctx);
61 * Retrieves classify table name for given id. If not present, artificial name will be generated.
63 * @param id classify table index
64 * @param ctx mapping context providing context data for current transaction
65 * @return classify table name matching supplied index
67 String getTableName(final int id, @Nonnull final MappingContext ctx);
70 * Returns name of the base vpp node associated with the classify table.
72 * @param name classify table name
73 * @param ctx mapping context providing context data for current transaction
74 * @return name of VPP node the table is defined for
76 Optional<String> getTableBaseNode(final String name, @Nonnull final MappingContext ctx);
79 * Removes classify table metadata from current context.
81 * @param name classify table name
82 * @param ctx mapping context providing context data for current transaction
84 void removeTable(@Nonnull final String name, @Nonnull final MappingContext ctx);
87 * Adds relative node index to node name mapping for given classify table.
89 * @param tableName classify table name
90 * @param nodeIndex index of a vpp node, relative to table's base node
91 * @param nodeName name of a vpp node
92 * @param ctx mapping context providing context data for current transaction
94 void addNodeName(@Nonnull String tableName, final int nodeIndex, @Nonnull final String nodeName,
95 @Nonnull final MappingContext ctx);
98 * Retrieves node name associated with the given classify table and node index.
100 * @param tableIndex classify table index
101 * @param nodeIndex relative index of a vpp node
102 * @param ctx mapping context providing context data for current transaction
103 * @return name of vpp node
105 Optional<String> getNodeName(final int tableIndex, final int nodeIndex, @Nonnull final MappingContext ctx);