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 #include "vom/sub_interface.hpp"
20 * Construct a new object matching the desried state
22 sub_interface::sub_interface(const interface& parent,
25 : interface(mk_name(parent, vlan), parent.type(), state)
26 , m_parent(parent.singular())
31 sub_interface::sub_interface(const handle_t& handle,
32 const interface& parent,
37 mk_name(parent, vlan),
40 , m_parent(parent.singular())
45 sub_interface::~sub_interface()
51 sub_interface::sub_interface(const sub_interface& o)
53 , m_parent(o.m_parent)
59 sub_interface::mk_name(const interface& parent, vlan_id_t vlan)
61 return (parent.name() + "." + std::to_string(vlan));
65 sub_interface::mk_create_cmd(std::queue<cmd*>& q)
67 q.push(new create_cmd(m_hdl, name(), m_parent->handle(), m_vlan));
73 sub_interface::mk_delete_cmd(std::queue<cmd*>& q)
75 q.push(new delete_cmd(m_hdl));
80 std::shared_ptr<sub_interface>
81 sub_interface::singular() const
83 return std::dynamic_pointer_cast<sub_interface>(singular_i());
86 std::shared_ptr<interface>
87 sub_interface::singular_i() const
89 return m_db.find_or_add(name(), *this);
94 * fd.io coding-style-patch-verification: ON
97 * eval: (c-set-style "mozilla")