Line data Source code
1 : /**
2 : * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 : * CANN Open Software License Agreement Version 2.0 (the "License").
5 : * Please refer to the License for details. You may not use this file except in compliance with the License.
6 : * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7 : * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 : * See LICENSE in the root of the software repository for the full text of the License.
9 : */
10 :
11 : #include "conn_interface.h"
12 : #include "string_util.h"
13 :
14 : namespace Hccl {
15 :
16 14 : ConnInterface::ConnInterface(
17 : const IpAddress inputAddr, const AddrPosition inputPos, const LinkType inputLinkType,
18 14 : const LinkProtocol inputLinkProtocol)
19 14 : : addr(inputAddr),
20 14 : pos(inputPos),
21 14 : linkType(inputLinkType),
22 14 : linkProtocol(inputLinkProtocol)
23 14 : {}
24 :
25 5 : IpAddress ConnInterface::GetAddr() const { return addr; }
26 :
27 5 : AddrPosition ConnInterface::GetPos() const { return pos; }
28 :
29 5 : LinkType ConnInterface::GetLinkType() const { return linkType; }
30 :
31 5 : LinkProtocol ConnInterface::GetLinkProtocol() const { return linkProtocol; }
32 :
33 1 : std::string ConnInterface::Describe() const
34 : {
35 1 : return StringFormat("ConnInterface[addr=%s, pos=%s]", addr.Describe().c_str(), pos.Describe().c_str());
36 : }
37 :
38 4 : bool ConnInterface::operator==(const ConnInterface& rhs) const
39 : {
40 4 : return addr == rhs.addr && pos == rhs.pos && linkType == rhs.linkType && linkProtocol == rhs.linkProtocol;
41 : }
42 :
43 2 : bool ConnInterface::operator!=(const ConnInterface& rhs) const { return !(rhs == *this); }
44 : } // namespace Hccl
|