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(const IpAddress inputAddr, const AddrPosition inputPos, const LinkType inputLinkType,
17 14 : const LinkProtocol inputLinkProtocol)
18 14 : : addr(inputAddr), pos(inputPos), linkType(inputLinkType), linkProtocol(inputLinkProtocol)
19 : {
20 14 : }
21 :
22 5 : IpAddress ConnInterface::GetAddr() const
23 : {
24 5 : return addr;
25 : }
26 :
27 5 : AddrPosition ConnInterface::GetPos() const
28 : {
29 5 : return pos;
30 : }
31 :
32 5 : LinkType ConnInterface::GetLinkType() const
33 : {
34 5 : return linkType;
35 : }
36 :
37 5 : LinkProtocol ConnInterface::GetLinkProtocol() const
38 : {
39 5 : return linkProtocol;
40 : }
41 :
42 1 : std::string ConnInterface::Describe() const
43 : {
44 1 : return StringFormat("ConnInterface[addr=%s, pos=%s]", addr.Describe().c_str(), pos.Describe().c_str());
45 : }
46 :
47 4 : bool ConnInterface::operator==(const ConnInterface &rhs) const
48 : {
49 4 : return addr == rhs.addr && pos == rhs.pos && linkType == rhs.linkType && linkProtocol == rhs.linkProtocol;
50 : }
51 :
52 2 : bool ConnInterface::operator!=(const ConnInterface &rhs) const
53 : {
54 2 : return !(rhs == *this);
55 : }
56 : } // namespace Hccl
|