Commit 1a7c1c88 authored by Matthias Vallentin's avatar Matthias Vallentin

Uses more intuitive inspector distinguishers

parent ecc37096
......@@ -170,7 +170,7 @@ public:
template <class D, atom_value V>
static error apply_atom_constant(D& self, atom_constant<V>&) {
static_assert(D::is_saving::value, "cannot deserialize an atom_constant");
static_assert(!D::writes_state, "cannot deserialize an atom_constant");
auto x = V;
return self.apply(x);
}
......@@ -275,7 +275,7 @@ public:
// Applies this processor as Derived to `xs` in saving mode.
template <class D, class T>
static typename std::enable_if<
D::is_saving::value && ! detail::is_byte_sequence<T>::value,
D::reads_state && ! detail::is_byte_sequence<T>::value,
error
>::type
apply_sequence(D& self, T& xs) {
......@@ -288,7 +288,7 @@ public:
// Applies this processor as Derived to `xs` in loading mode.
template <class D, class T>
static typename std::enable_if<
! D::is_saving::value && ! detail::is_byte_sequence<T>::value,
! D::reads_state && ! detail::is_byte_sequence<T>::value,
error
>::type
apply_sequence(D& self, T& xs) {
......@@ -301,7 +301,7 @@ public:
// Optimized saving for contiguous byte sequences.
template <class D, class T>
static typename std::enable_if<
D::is_saving::value && detail::is_byte_sequence<T>::value,
D::reads_state && detail::is_byte_sequence<T>::value,
error
>::type
apply_sequence(D& self, T& xs) {
......@@ -314,7 +314,7 @@ public:
// Optimized loading for contiguous byte sequences.
template <class D, class T>
static typename std::enable_if<
! D::is_saving::value && detail::is_byte_sequence<T>::value,
! D::reads_state && detail::is_byte_sequence<T>::value,
error
>::type
apply_sequence(D& self, T& xs) {
......@@ -443,7 +443,7 @@ public:
template <class F, class... Ts>
error operator()(meta::save_callback_t<F> x, Ts&&... xs) {
error e;
if (Derived::is_saving::value)
if (Derived::reads_state)
e = x.fun();
return e ? e : (*this)(std::forward<Ts>(xs)...);
}
......@@ -451,7 +451,7 @@ public:
template <class F, class... Ts>
error operator()(meta::load_callback_t<F> x, Ts&&... xs) {
error e;
if (Derived::is_loading::value)
if (Derived::writes_state)
e = x.fun();
return e ? e : (*this)(std::forward<Ts>(xs)...);
}
......@@ -477,7 +477,7 @@ public:
error
>::type
operator()(T&& x, Ts&&... xs) {
static_assert(Derived::is_saving::value
static_assert(Derived::reads_state
|| (! std::is_rvalue_reference<T&&>::value
&& ! std::is_const<
typename std::remove_reference<T>::type
......@@ -498,14 +498,14 @@ private:
}
template <class D, class T, class U, class F>
static typename std::enable_if<D::is_saving::value, error>::type
static typename std::enable_if<D::reads_state, error>::type
convert_apply(D& self, T& x, U& storage, F assign) {
assign(storage, x);
return self.apply(storage);
}
template <class D, class T, class U, class F>
static typename std::enable_if<! D::is_saving::value, error>::type
static typename std::enable_if<! D::reads_state, error>::type
convert_apply(D& self, T& x, U& storage, F assign) {
auto e = self.apply(storage);
if (e)
......
......@@ -44,8 +44,11 @@ public:
using super = data_processor<deserializer>;
using is_saving = std::false_type;
static constexpr bool reads_state = false;
static constexpr bool writes_state = true;
// Boost Serialization compatibility
using is_saving = std::false_type;
using is_loading = std::true_type;
explicit deserializer(actor_system& sys);
......
......@@ -49,7 +49,7 @@ public:
using result_type = void;
using is_saving = std::true_type;
static constexpr bool reads_state = true;
// -- constructors, destructors, and assignment operators --------------------
......
......@@ -129,7 +129,7 @@ public:
explicit node_id(intrusive_ptr<data> dataptr);
template <class Inspector>
friend detail::enable_if_t<Inspector::is_saving::value,
friend detail::enable_if_t<Inspector::reads_state,
typename Inspector::result_type>
inspect(Inspector& f, node_id& x) {
data tmp;
......@@ -139,7 +139,7 @@ public:
}
template <class Inspector>
friend detail::enable_if_t<Inspector::is_loading::value,
friend detail::enable_if_t<Inspector::writes_state,
typename Inspector::result_type>
inspect(Inspector& f, node_id& x) {
data tmp;
......
......@@ -262,7 +262,7 @@ class optional<void> {
};
template <class Inspector, class T>
typename std::enable_if<Inspector::is_saving::value,
typename std::enable_if<Inspector::reads_state,
typename Inspector::result_type>::type
inspect(Inspector& f, optional<T>& x) {
return x ? f(true, *x) : f(false);
......@@ -280,7 +280,7 @@ struct optional_inspect_helper {
};
template <class Inspector, class T>
typename std::enable_if<Inspector::is_loading::value,
typename std::enable_if<Inspector::writes_state,
typename Inspector::result_type>::type
inspect(Inspector& f, optional<T>& x) {
bool flag;
......
......@@ -41,8 +41,11 @@ class serializer : public data_processor<serializer> {
public:
using super = data_processor<serializer>;
using is_saving = std::true_type;
static constexpr bool reads_state = true;
static constexpr bool writes_state = false;
// Boost Serialization compatibility
using is_saving = std::true_type;
using is_loading = std::false_type;
explicit serializer(actor_system& sys);
......
......@@ -191,14 +191,14 @@ private:
/// @relates type_erased_tuple
template <class Processor>
typename std::enable_if<Processor::is_saving::value>::type
typename std::enable_if<Processor::reads_state>::type
serialize(Processor& proc, type_erased_tuple& x) {
x.save(proc);
}
/// @relates type_erased_tuple
template <class Processor>
typename std::enable_if<Processor::is_loading::value>::type
typename std::enable_if<Processor::writes_state>::type
serialize(Processor& proc, type_erased_tuple& x) {
x.load(proc);
}
......
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