Remove obsolete classes and headers

parent 52914200
......@@ -164,7 +164,6 @@ caf_add_component(
src/logger.cpp
src/mailbox_element.cpp
src/make_config_option.cpp
src/memory_managed.cpp
src/message.cpp
src/message_builder.cpp
src/message_handler.cpp
......
......@@ -59,7 +59,6 @@
#include "caf/logger.hpp"
#include "caf/make_config_option.hpp"
#include "caf/may_have_timeout.hpp"
#include "caf/memory_managed.hpp"
#include "caf/message.hpp"
#include "caf/message_builder.hpp"
#include "caf/message_handler.hpp"
......
// Deprecated include. The next CAF release won't include this header.
// This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#pragma once
#include "caf/detail/core_export.hpp"
namespace caf {
class [[deprecated]] memory_managed;
class CAF_CORE_EXPORT memory_managed {
public:
virtual void request_deletion(bool decremented_rc) const noexcept;
protected:
virtual ~memory_managed();
};
} // namespace caf
// This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#pragma once
namespace caf {
template <class Result = void>
struct static_visitor {
using result_type = Result;
};
} // namespace caf
// This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#pragma once
#include <cstdint>
#include <functional>
#include <typeinfo>
#include "caf/detail/core_export.hpp"
#include "caf/error_code.hpp"
#include "caf/fwd.hpp"
#include "caf/rtti_pair.hpp"
#include "caf/type_nr.hpp"
namespace caf {
/// Represents a single type-erased value.
class CAF_CORE_EXPORT type_erased_value {
public:
// -- constructors, destructors, and assignment operators --------------------
virtual ~type_erased_value();
// -- pure virtual modifiers -------------------------------------------------
/// Returns a mutable pointer to the stored value.
virtual void* get_mutable() = 0;
/// Load the content for the stored value from `source`.
virtual error load(deserializer& source) = 0;
/// Load the content for the stored value from `source`.
virtual error_code<sec> load(binary_deserializer& source) = 0;
// -- pure virtual observers -------------------------------------------------
/// Returns the type number and type information object for the stored value.
virtual rtti_pair type() const = 0;
/// Returns a pointer to the stored value.
virtual const void* get() const = 0;
/// Saves the content of the stored value to `sink`.
virtual error save(serializer& sink) const = 0;
/// Saves the content of the stored value to `sink`.
virtual error_code<sec> save(binary_serializer& sink) const = 0;
/// Converts the stored value to a string.
virtual std::string stringify() const = 0;
/// Returns a copy of the stored value.
virtual type_erased_value_ptr copy() const = 0;
// -- observers --------------------------------------------------------------
/// Checks whether the type of the stored value matches
/// the type nr and type info object.
bool matches(uint16_t nr, const std::type_info* ptr) const;
// -- convenience functions --------------------------------------------------
/// Returns the type number for the stored value.
uint16_t type_nr() const {
return type().first;
}
/// Checks whether the type of the stored value matches `rtti`.
bool matches(const rtti_pair& rtti) const {
return matches(rtti.first, rtti.second);
}
/// Convenience function for `reinterpret_cast<const T*>(get())`.
template <class T>
const T& get_as() const {
return *reinterpret_cast<const T*>(get());
}
/// Convenience function for `reinterpret_cast<T*>(get_mutable())`.
template <class T>
T& get_mutable_as() {
return *reinterpret_cast<T*>(get_mutable());
}
};
/// @relates type_erased_value
CAF_CORE_EXPORT error inspect(serializer& f, const type_erased_value& x);
/// @relates type_erased_value
CAF_CORE_EXPORT error inspect(deserializer& f, type_erased_value& x);
/// @relates type_erased_value
inline auto inspect(binary_serializer& f, const type_erased_value& x) {
return x.save(f);
}
/// @relates type_erased_value
inline auto inspect(binary_deserializer& f, type_erased_value& x) {
return x.load(f);
}
/// @relates type_erased_value
inline auto to_string(const type_erased_value& x) {
return x.stringify();
}
} // namespace caf
......@@ -15,7 +15,6 @@
#include "caf/detail/variant_data.hpp"
#include "caf/fwd.hpp"
#include "caf/raise_error.hpp"
#include "caf/static_visitor.hpp"
#include "caf/sum_type.hpp"
#include "caf/sum_type_access.hpp"
......@@ -26,10 +25,8 @@
#define CAF_VARIANT_ASSIGN_CASE(n) \
case n: { \
using tmp_t = typename detail::tl_at< \
detail::type_list<Ts...>, \
(n < sizeof...(Ts) ? n : 0) \
>::type; \
using tmp_t = typename detail::tl_at<detail::type_list<Ts...>, \
(n < sizeof...(Ts) ? n : 0)>::type; \
x.x = tmp_t{}; \
return f(get<tmp_t>(x.x)); \
}
......@@ -60,7 +57,8 @@ template <class T>
struct variant_assign_helper {
using result_type = void;
T& lhs;
variant_assign_helper(T& lhs_ref) : lhs(lhs_ref) { }
variant_assign_helper(T& lhs_ref) : lhs(lhs_ref) {
}
template <class U>
void operator()(const U& rhs) const {
lhs = rhs;
......@@ -71,7 +69,8 @@ template <class T>
struct variant_move_helper {
using result_type = void;
T& lhs;
variant_move_helper(T& lhs_ref) : lhs(lhs_ref) { }
variant_move_helper(T& lhs_ref) : lhs(lhs_ref) {
}
template <class U>
void operator()(U& rhs) const {
lhs = std::move(rhs);
......@@ -80,8 +79,8 @@ struct variant_move_helper {
template <bool Valid, class F, class... Ts>
struct variant_visit_result_impl {
using type =
decltype((std::declval<F&>())(std::declval<typename Ts::type0&>()...));
using type
= decltype((std::declval<F&>())(std::declval<typename Ts::type0&>()...));
};
template <class F, class... Ts>
......@@ -89,8 +88,8 @@ struct variant_visit_result_impl<false, F, Ts...> {};
template <class F, class... Ts>
struct variant_visit_result
: variant_visit_result_impl<
detail::conjunction<is_variant<Ts>::value...>::value, F, Ts...> {};
: variant_visit_result_impl<
detail::conjunction<is_variant<Ts>::value...>::value, F, Ts...> {};
template <class F, class... Ts>
using variant_visit_result_t =
......@@ -113,19 +112,16 @@ public:
static constexpr int max_type_id = sizeof...(Ts) - 1;
/// Stores whether all types are nothrow constructible.
static constexpr bool nothrow_move_construct =
detail::conjunction<
std::is_nothrow_move_constructible<Ts>::value...
>::value;
static constexpr bool nothrow_move_construct = detail::conjunction<
std::is_nothrow_move_constructible<Ts>::value...>::value;
/// Stores whether all types are nothrow assignable *and* constructible. We
/// need to check both, since assigning to a variant results in a
/// move-construct unless the before and after types are the same.
static constexpr bool nothrow_move_assign =
nothrow_move_construct
&& detail::conjunction<
std::is_nothrow_move_assignable<Ts>::value...
>::value;
/// move-contruct unless the before and after types are the same.
static constexpr bool nothrow_move_assign
= nothrow_move_construct
&& detail::conjunction<
std::is_nothrow_move_assignable<Ts>::value...>::value;
// -- sanity checks ----------------------------------------------------------
......@@ -146,14 +142,14 @@ public:
}
template <class U>
variant(U&& arg)
noexcept(std::is_rvalue_reference<U&&>::value && nothrow_move_assign)
: type_(variant_npos) {
variant(U&& arg) noexcept(
std::is_rvalue_reference<U&&>::value&& nothrow_move_assign)
: type_(variant_npos) {
set(std::forward<U>(arg));
}
variant(variant&& other) noexcept(nothrow_move_construct)
: type_(variant_npos) {
: type_(variant_npos) {
variant_move_helper<variant> helper{*this};
other.template apply<void>(helper);
}
......@@ -246,37 +242,38 @@ public:
template <class Result, class Self, class Visitor, class... Us>
static Result apply_impl(Self& x, Visitor&& f, Us&&... xs) {
switch (x.type_) {
default: CAF_RAISE_ERROR("invalid type found");
CAF_VARIANT_CASE(0);
CAF_VARIANT_CASE(1);
CAF_VARIANT_CASE(2);
CAF_VARIANT_CASE(3);
CAF_VARIANT_CASE(4);
CAF_VARIANT_CASE(5);
CAF_VARIANT_CASE(6);
CAF_VARIANT_CASE(7);
CAF_VARIANT_CASE(8);
CAF_VARIANT_CASE(9);
CAF_VARIANT_CASE(10);
CAF_VARIANT_CASE(11);
CAF_VARIANT_CASE(12);
CAF_VARIANT_CASE(13);
CAF_VARIANT_CASE(14);
CAF_VARIANT_CASE(15);
CAF_VARIANT_CASE(16);
CAF_VARIANT_CASE(17);
CAF_VARIANT_CASE(18);
CAF_VARIANT_CASE(19);
CAF_VARIANT_CASE(20);
CAF_VARIANT_CASE(21);
CAF_VARIANT_CASE(22);
CAF_VARIANT_CASE(23);
CAF_VARIANT_CASE(24);
CAF_VARIANT_CASE(25);
CAF_VARIANT_CASE(26);
CAF_VARIANT_CASE(27);
CAF_VARIANT_CASE(28);
CAF_VARIANT_CASE(29);
default:
CAF_RAISE_ERROR("invalid type found");
CAF_VARIANT_CASE(0);
CAF_VARIANT_CASE(1);
CAF_VARIANT_CASE(2);
CAF_VARIANT_CASE(3);
CAF_VARIANT_CASE(4);
CAF_VARIANT_CASE(5);
CAF_VARIANT_CASE(6);
CAF_VARIANT_CASE(7);
CAF_VARIANT_CASE(8);
CAF_VARIANT_CASE(9);
CAF_VARIANT_CASE(10);
CAF_VARIANT_CASE(11);
CAF_VARIANT_CASE(12);
CAF_VARIANT_CASE(13);
CAF_VARIANT_CASE(14);
CAF_VARIANT_CASE(15);
CAF_VARIANT_CASE(16);
CAF_VARIANT_CASE(17);
CAF_VARIANT_CASE(18);
CAF_VARIANT_CASE(19);
CAF_VARIANT_CASE(20);
CAF_VARIANT_CASE(21);
CAF_VARIANT_CASE(22);
CAF_VARIANT_CASE(23);
CAF_VARIANT_CASE(24);
CAF_VARIANT_CASE(25);
CAF_VARIANT_CASE(26);
CAF_VARIANT_CASE(27);
CAF_VARIANT_CASE(28);
CAF_VARIANT_CASE(29);
}
}
......@@ -284,7 +281,8 @@ public:
private:
void destroy_data() {
if (type_ == variant_npos) return; // nothing to do
if (type_ == variant_npos)
return; // nothing to do
detail::variant_data_destructor f;
apply<void>(f);
}
......@@ -293,20 +291,17 @@ private:
void set(U&& arg) {
using namespace detail;
using type = typename std::decay<U>::type;
static constexpr int type_id =
detail::tl_index_where<
types,
detail::tbind<is_same_ish, type>::template type
>::value;
static constexpr int type_id = detail::tl_index_where<
types, detail::tbind<is_same_ish, type>::template type>::value;
static_assert(type_id >= 0, "invalid type for variant");
std::integral_constant<int, type_id> token;
if (type_ != type_id) {
destroy_data();
type_ = type_id;
auto& ref = data_.get(token);
new (std::addressof(ref)) type (std::forward<U>(arg));
new (std::addressof(ref)) type(std::forward<U>(arg));
} else {
data_.get(token) = std::forward<U>(arg);
data_.get(token) = std::forward<U>(arg);
}
}
......@@ -346,7 +341,7 @@ private:
/// @relates SumType
template <class... Ts>
struct sum_type_access<variant<Ts...>>
: default_sum_type_access<variant<Ts...>> {
: default_sum_type_access<variant<Ts...>> {
// nop
};
......
// This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#include "caf/memory_managed.hpp"
namespace caf {
memory_managed::~memory_managed() {
// nop
}
void memory_managed::request_deletion(bool) const noexcept {
delete this;
}
} // namespace caf
......@@ -8,14 +8,13 @@
#include "core-test.hpp"
#include <new>
#include <map>
#include <new>
#include <string>
#include "caf/default_sum_type_access.hpp"
#include "caf/detail/overload.hpp"
#include "caf/raise_error.hpp"
#include "caf/static_visitor.hpp"
#include "caf/sum_type_access.hpp"
namespace {
......@@ -106,9 +105,12 @@ private:
template <class Result, class Visitor, class... Ts>
inline Result apply(Visitor&& f, Ts&&... xs) const {
switch (index_) {
case 0: return f(std::forward<Ts>(xs)..., v0);
case 1: return f(std::forward<Ts>(xs)..., v1);
case 2: return f(std::forward<Ts>(xs)..., v2);
case 0:
return f(std::forward<Ts>(xs)..., v0);
case 1:
return f(std::forward<Ts>(xs)..., v1);
case 2:
return f(std::forward<Ts>(xs)..., v2);
}
CAF_RAISE_ERROR("invalid index in union_type");
}
......@@ -159,12 +161,12 @@ struct stringify_t {
template <class T0, class T1>
string operator()(const T0& x0, const T1& x1) const {
return (*this)(x0) + ", " + (*this)(x1);
return (*this) (x0) + ", " + (*this) (x1);
}
template <class T0, class T1, class T2>
string operator()(const T0& x0, const T1& x1, const T2& x2) const {
return (*this)(x0, x1) + ", " + (*this)(x2);
return (*this) (x0, x1) + ", " + (*this) (x2);
}
};
......@@ -235,7 +237,7 @@ CAF_TEST(ternary visit) {
union_type x;
union_type y;
union_type z;
//CAF_CHECK_EQUAL(visit(stringify, x, y, z), "0, 0, 0");
// CAF_CHECK_EQUAL(visit(stringify, x, y, z), "0, 0, 0");
x = 42;
y = string{"foo"};
z = map_type{{1, 1}, {2, 2}};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment