2 * Copyright (c) 2017 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 #ifndef __VOM_SUB_INTERFACE_H__
17 #define __VOM_SUB_INTERFACE_H__
19 #include "vom/interface.hpp"
23 * A Sub-interface. e.g. a VLAN sub-interface on an Ethernet interface
25 class sub_interface : public interface
30 typedef uint16_t vlan_id_t;
34 * Construct a new object matching the desried state
36 sub_interface(const interface& parent, admin_state_t state, vlan_id_t vlan);
44 sub_interface(const sub_interface& o);
47 * Return the matching 'singular instance' of the sub-interface
49 std::shared_ptr<sub_interface> singular() const;
53 * Construct with handle
55 sub_interface(const handle_t& handle,
56 const interface& parent,
59 friend class interface_factory;
62 * The interface class can construct interfaces with handles
64 friend class interface;
67 * Return the matching 'instance' of the sub-interface
68 * over-ride from the base class
70 std::shared_ptr<interface> singular_i() const;
73 * Virtual functions to construct an interface create commands.
75 virtual std::queue<cmd*>& mk_create_cmd(std::queue<cmd*>& cmds);
78 * Virtual functions to construct an interface delete commands.
80 virtual std::queue<cmd*>& mk_delete_cmd(std::queue<cmd*>& cmds);
83 * From the name of the parent and the vlan,
84 * construct the sub-interface's name
86 static std::string mk_name(const interface& parent, vlan_id_t vlan);
89 * Refernece conter lock on the parent
91 const std::shared_ptr<interface> m_parent;
101 * fd.io coding-style-patch-verification: ON
104 * eval: (c-set-style "mozilla")