• 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

52.63
/libs/core/functional/include/hpx/functional/serialization/detail/serializable_basic_function.hpp
1
//  Copyright (c) 2011 Thomas Heller
2
//  Copyright (c) 2013-2023 Hartmut Kaiser
3
//  Copyright (c) 2014-2019 Agustin Berge
4
//  Copyright (c) 2017 Google
5
//
6
//  SPDX-License-Identifier: BSL-1.0
7
//  Distributed under the Boost Software License, Version 1.0. (See accompanying
8
//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9

10
#pragma once
11

12
#include <hpx/functional/detail/basic_function.hpp>
13
#include <hpx/functional/detail/vtable/function_vtable.hpp>
14
#include <hpx/functional/detail/vtable/vtable.hpp>
15
#include <hpx/functional/serialization/detail/vtable/serializable_function_vtable.hpp>
16
#include <hpx/functional/serialization/detail/vtable/serializable_vtable.hpp>
17
#include <hpx/modules/serialization.hpp>
18

19
#include <string>
20
#include <type_traits>
21
#include <utility>
22

23
namespace hpx::util::detail {
24

25
    template <bool Copyable, typename R, typename... Ts>
26
    class basic_function<R(Ts...), Copyable, /*Serializable*/ true>
81,488✔
27
      : public basic_function<R(Ts...), Copyable, /*Serializable*/ false>
28
    {
29
        using vtable = function_vtable<R(Ts...), Copyable>;
30
        using serializable_vtable = serializable_function_vtable<vtable>;
31
        using base_type = basic_function<R(Ts...), Copyable, false>;
32

33
    public:
34
        constexpr basic_function() noexcept
41,311✔
35
          : base_type()
36
          , serializable_vptr(nullptr)
41,311✔
37
        {
38
        }
39

40
        template <typename F>
41
        void assign(F&& f)
42
        {
43
            using target_type = std::decay_t<F>;
44

45
            base_type::assign(HPX_FORWARD(F, f));
×
46
            if (!base_type::empty())
×
47
            {
48
                serializable_vptr = get_serializable_vtable<target_type>();
×
49
            }
50
        }
51

52
        void swap(basic_function& f) noexcept
53
        {
54
            base_type::swap(f);
55
            std::swap(serializable_vptr, f.serializable_vptr);
56
        }
57

58
    private:
59
        friend class hpx::serialization::access;
60

61
        void save(
366✔
62
            serialization::output_archive& ar, unsigned const version) const
63
        {
64
            bool const is_empty = base_type::empty();
65
            ar << is_empty;
66
            if (!is_empty)
366✔
67
            {
68
                ar << std::string(serializable_vptr->name);
×
69
                serializable_vptr->save_object(object, ar, version);
×
70
            }
71
        }
366✔
72

73
        void load(serialization::input_archive& ar, unsigned const version)
183✔
74
        {
75
            base_type::reset();
76

77
            bool is_empty = false;
183✔
78
            ar >> is_empty;
79
            if (!is_empty)
183✔
80
            {
81
                std::string name;
82
                ar >> name;
83
                serializable_vptr =
×
84
                    detail::get_serializable_vtable<vtable>(HPX_MOVE(name));
85

86
                vptr = serializable_vptr->vptr;
×
87
                object = serializable_vptr->load_object(
×
88
                    storage, function_storage_size, ar, version);
×
89
            }
90
        }
183✔
91

92
        HPX_SERIALIZATION_SPLIT_MEMBER()
93

94
        template <typename T>
95
        static constexpr serializable_vtable const*
96
        get_serializable_vtable() noexcept
97
        {
98
            return detail::get_serializable_vtable<vtable, T>();
99
        }
100

101
    protected:
102
        using base_type::object;
103
        using base_type::storage;
104
        using base_type::vptr;
105
        serializable_vtable const* serializable_vptr;
106
    };
107
}    // namespace hpx::util::detail
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

© 2026 Coveralls, Inc