• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

STEllAR-GROUP / hpx / #882

31 Aug 2023 07:44PM UTC coverage: 41.798% (-44.7%) from 86.546%
#882

push

19442 of 46514 relevant lines covered (41.8%)

126375.38 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

79.17
/libs/full/parcelset_base/src/locality.cpp
1
//  Copyright (c)      2014 Thomas Heller
2
//  Copyright (c) 2007-2024 Hartmut Kaiser
3
//
4
//  SPDX-License-Identifier: BSL-1.0
5
//  Distributed under the Boost Software License, Version 1.0. (See accompanying
6
//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7

8
#include <hpx/config.hpp>
9
#include <hpx/assert.hpp>
10
#include <hpx/modules/errors.hpp>
11
#include <hpx/modules/serialization.hpp>
12
#include <hpx/modules/type_support.hpp>
13
#include <hpx/modules/util.hpp>
14

15
#include <hpx/parcelset_base/locality.hpp>
16
#include <hpx/parcelset_base/locality_interface.hpp>
17

18
#include <string>
19
#include <utility>
20

21
///////////////////////////////////////////////////////////////////////////////
22
namespace hpx::parcelset {
23

24
    locality::locality(locality const& other)
2,239✔
25
      : impl_(other.impl_ ? other.impl_->clone() : nullptr)
2,239✔
26
    {
27
    }
2,239✔
28

29
    locality::locality(locality&& other) noexcept
68✔
30
      : impl_(other.impl_ ? other.impl_->move() : nullptr)
68✔
31
    {
32
    }
68✔
33

34
    locality& locality::operator=(locality const& other)
19✔
35
    {
36
        if (this != &other)
19✔
37
        {
38
            if (other.impl_)
19✔
39
            {
40
                impl_.reset(other.impl_->clone());
19✔
41
            }
42
            else
43
            {
44
                impl_.reset();
45
            }
46
        }
47
        return *this;
19✔
48
    }
49

50
    locality& locality::operator=(locality&& other) noexcept
12✔
51
    {
52
        if (this != &other)
12✔
53
        {
54
            if (other.impl_)
12✔
55
            {
56
                impl_.reset(other.impl_->move());
6✔
57
            }
58
            else
59
            {
60
                impl_.reset();
61
            }
62
        }
63
        return *this;
12✔
64
    }
65

66
    ///////////////////////////////////////////////////////////////////////////
67
    bool operator==(locality const& lhs, locality const& rhs)
×
68
    {
69
        if (lhs.impl_ == rhs.impl_)
×
70
            return true;
71
        if (!lhs.impl_ || !rhs.impl_)
×
72
            return false;
73
        return lhs.impl_->equal(*rhs.impl_);
×
74
    }
75

76
    bool operator!=(locality const& lhs, locality const& rhs)
×
77
    {
78
        return !(lhs == rhs);
×
79
    }
80

81
    bool operator<(locality const& lhs, locality const& rhs)
4,056✔
82
    {
83
        if (lhs.impl_ == rhs.impl_)
4,056✔
84
            return false;
85
        if (!lhs.impl_ || !rhs.impl_)
4,056✔
86
            return false;
87
        return lhs.impl_->less_than(*rhs.impl_);
4,056✔
88
    }
89

90
    bool operator>(locality const& lhs, locality const& rhs)
×
91
    {
92
        if (lhs.impl_ == rhs.impl_)
×
93
            return false;
94
        if (!lhs.impl_ || !rhs.impl_)
×
95
            return false;
96
        return !(lhs < rhs) && lhs != rhs;
×
97
    }
98

99
    ///////////////////////////////////////////////////////////////////////////
100
    std::ostream& operator<<(std::ostream& os, locality const& l)
10✔
101
    {
102
        if (!l.impl_)
10✔
103
            return os;
104
        return l.impl_->print(os);
10✔
105
    }
106

107
    ///////////////////////////////////////////////////////////////////////////
108
    void locality::save(
69✔
109
        [[maybe_unused]] serialization::output_archive& ar, unsigned int) const
110
    {
111
#if defined(HPX_HAVE_NETWORKING)
112
        std::string const t = type();
69✔
113
        ar << t;
114
        if (t.empty())
69✔
115
        {
116
            return;
117
        }
118

119
        impl_->save(ar);
69✔
120
#else
121
        HPX_THROW_EXCEPTION(hpx::error::invalid_status, "locality::save",
122
            "this shouldn't be called if networking is disabled");
123
#endif
124
    }
125

126
    void locality::load(
23✔
127
        [[maybe_unused]] serialization::input_archive& ar, unsigned int)
128
    {
129
#if defined(HPX_HAVE_NETWORKING)
130
        std::string t;
131
        ar >> t;
132
        if (t.empty())
23✔
133
        {
134
            return;
135
        }
136

137
        impl_ = HPX_MOVE(create_locality(t).impl_);
46✔
138
        impl_->load(ar);
23✔
139
        HPX_ASSERT(impl_->valid());
140
#else
141
        HPX_THROW_EXCEPTION(hpx::error::invalid_status, "locality::load",
142
            "this shouldn't be called if networking is disabled");
143
#endif
144
    }
145

146
    std::ostream& operator<<(std::ostream& os, endpoints_type const& endpoints)
34✔
147
    {
148
        hpx::util::ios_flags_saver ifs(os);
34✔
149
        os << "[ ";
34✔
150
        for (endpoints_type::value_type const& loc : endpoints)
44✔
151
        {
152
            os << "(" << loc.first << ":" << loc.second << ") ";
10✔
153
        }
154
        os << "]";
34✔
155

156
        return os;
34✔
157
    }
158
}    // namespace hpx::parcelset
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc