Commit 217c2f50 authored by Matthias Vallentin's avatar Matthias Vallentin

Unify generic serialization parameter naming

parent 20047855
......@@ -51,10 +51,10 @@ namespace detail {
// Calls `serialize(...)` with `using namespace boost::serialization`
// to enable both ADL and picking up existing boost code.
template <class T, class U>
void delegate_serialize(T& in_or_out, U& x) {
template <class Processor, class U>
void delegate_serialize(Processor& proc, U& x) {
using namespace boost::serialization;
serialize(in_or_out, x, 0);
serialize(proc, x, 0);
}
} // namespace detail
......
......@@ -23,13 +23,13 @@
namespace caf {
namespace detail {
template <class T, class U>
auto try_serialize(T& in_or_out, U* x) -> decltype(in_or_out & *x) {
in_or_out & *x;
template <class Processor, class U>
auto try_serialize(Processor& proc, U* x) -> decltype(proc & *x) {
proc & *x;
}
template <class T>
void try_serialize(T&, const void*) {
template <class Processor>
void try_serialize(Processor&, const void*) {
// nop
}
......
......@@ -57,12 +57,12 @@ struct tup_ptr_access {
return tup_ptr_access<Pos + 1, Max>::cmp(pos, tup, x);
}
template <class T, class U>
static void serialize(size_t pos, T& tup, U& in_or_out) {
template <class T, class Processor>
static void serialize(size_t pos, T& tup, Processor& proc) {
if (pos == Pos)
try_serialize(in_or_out, &std::get<Pos>(tup));
try_serialize(proc, &std::get<Pos>(tup));
else
tup_ptr_access<Pos + 1, Max>::serialize(pos, tup, in_or_out);
tup_ptr_access<Pos + 1, Max>::serialize(pos, tup, proc);
}
template <class T>
......@@ -91,8 +91,8 @@ struct tup_ptr_access<Pos, Max, false> {
return false;
}
template <class T, class U>
static void serialize(size_t, T&, U&) {
template <class T, class Processor>
static void serialize(size_t, T&, Processor&) {
// end of recursion
}
......
......@@ -259,7 +259,7 @@ template <class F, class S>
struct is_tuple<std::pair<F, S>> : std::true_type { };
/// Checks whether `T` provides a free
/// `serialize(InOut&, T&, const unsigned int)` function.
/// `serialize(Processor&, T&, const unsigned int)` function.
template <class T>
struct has_free_serialize {
private:
......@@ -284,7 +284,7 @@ public:
};
/// Checks whether `T` provides a member
/// `T::serialize(InOut&, const unsigned int)` function.
/// `T::serialize(Processor&, const unsigned int)` function.
template <class T>
struct has_member_serialize {
private:
......@@ -309,8 +309,8 @@ public:
};
/// Checks whether `T` provides either a free function
/// `serialize(InOut&, T&, const unsigned int)` or a member function
/// `T::serialize(InOut&, const unsigned int)`. If `T` is iterable,
/// `serialize(Processor&, T&, const unsigned int)` or a member function
/// `T::serialize(Processor&, const unsigned int)`. If `T` is iterable,
/// then the template checks whether `T::value_type` is serializable.
template <class T,
bool Ignore = std::is_pointer<T>::value
......
......@@ -126,10 +126,10 @@ private:
};
/// @relates duration
template <class T>
void serialize(T& in_out, duration& x, const unsigned int) {
in_out & x.unit;
in_out & x.count;
template <class Processor>
void serialize(Processor& proc, duration& x, const unsigned int) {
proc & x.unit;
proc & x.count;
}
/// @relates duration
......
......@@ -49,9 +49,9 @@ inline bool operator==(const index_mapping& x, const index_mapping& y) {
return x.value == y.value;
}
template <class T>
void serialize(T& in_or_out, index_mapping& x, const unsigned int) {
in_or_out & x.value;
template <class Processor>
void serialize(Processor& proc, index_mapping& x, const unsigned int) {
proc & x.value;
}
inline std::string to_string(const index_mapping& x) {
......
......@@ -637,9 +637,9 @@ bool operator!=(const none_t&, const maybe<T>& x) {
}
/// @relates maybe
template <class InOrOut, class T>
typename std::enable_if<InOrOut::is_saving::value>::type
serialize(InOrOut& sink, maybe<T>& x, const unsigned int) {
template <class Processor, class T>
typename std::enable_if<Processor::is_saving::value>::type
serialize(Processor& sink, maybe<T>& x, const unsigned int) {
uint8_t flag = x.empty() ? 0 : (x.valid() ? 1 : 2);
sink & flag;
if (x.valid())
......@@ -651,9 +651,9 @@ serialize(InOrOut& sink, maybe<T>& x, const unsigned int) {
}
/// @relates maybe
template <class InOrOut, class T>
typename std::enable_if<InOrOut::is_loading::value>::type
serialize(InOrOut& source, maybe<T>& x, const unsigned int) {
template <class Processor, class T>
typename std::enable_if<Processor::is_loading::value>::type
serialize(Processor& source, maybe<T>& x, const unsigned int) {
uint8_t flag;
source & flag;
switch (flag) {
......
......@@ -414,8 +414,8 @@ make_message(T&& x, Ts&&... xs) {
>;
static_assert(tl_forall<stored_types, is_serializable_or_whitelisted>::value,
"at least one type is not serializable via free "
"'serialize(InOrOut&, T&, const unsigned int)' or "
"`T::serialize(InOrOut&, const unsigned int)` "
"'serialize(Processor&, T&, const unsigned int)' or "
"`T::serialize(Processor&, const unsigned int)` "
"member function; you can whitelist individual types by "
"specializing `caf::allowed_unsafe_message_type<T>` "
"or using the macro CAF_ALLOW_UNSAFE_MESSAGE_TYPE");
......
......@@ -43,8 +43,8 @@ struct none_t : detail::comparable<none_t> {
static constexpr none_t none = none_t{};
/// @relates none_t
template <class T>
void serialize(T&, const none_t&, const unsigned int) {
template <class Processor>
void serialize(Processor&, const none_t&, const unsigned int) {
// nop
}
......
......@@ -84,7 +84,7 @@ operator!=(const T& lhs, const T& rhs) {
return !(lhs == rhs);
}
template <class IO, class T>
template <class Processor, class T>
typename std::enable_if<
detail::tl_exists<
detail::type_list<exit_msg, down_msg>,
......@@ -94,9 +94,9 @@ typename std::enable_if<
>::template type
>::value
>::type
serialize(IO& in_or_out, T& x, const unsigned int) {
in_or_out & x.source;
in_or_out & x.reason;
serialize(Processor& proc, T& x, const unsigned int) {
proc & x.source;
proc & x.reason;
}
/// Sent to all members of a group when it goes offline.
......@@ -120,9 +120,9 @@ inline bool operator!=(const group_down_msg& lhs, const group_down_msg& rhs) {
}
/// @relates group_down_msg
template <class IO>
void serialize(IO& in_or_out, group_down_msg& x, const unsigned int) {
in_or_out & x.source;
template <class Processor>
void serialize(Processor& proc, group_down_msg& x, const unsigned int) {
proc & x.source;
}
/// Sent whenever a timeout occurs during a synchronous send.
......@@ -166,9 +166,9 @@ inline bool operator!=(const timeout_msg& lhs, const timeout_msg& rhs) {
}
/// @relates timeout_msg
template <class IO>
void serialize(IO& in_or_out, timeout_msg& x, const unsigned int) {
in_or_out & x.timeout_id;
template <class Processor>
void serialize(Processor& proc, timeout_msg& x, const unsigned int) {
proc & x.timeout_id;
}
} // namespace caf
......
......@@ -193,22 +193,22 @@ struct type_erased_value_impl<T[N]> : public type_erased_value {
array_copy_impl(lhs, rhs, token);
}
template <class A, class U, size_t Len>
static void array_serialize_impl(A& in_out, U (&ys)[Len], std::true_type) {
template <class P, class U, size_t Len>
static void array_serialize_impl(P& proc, U (&ys)[Len], std::true_type) {
for (auto& y : ys)
array_serialize(in_out, y);
array_serialize(proc, y);
}
template <class A, class U, size_t Len>
static void array_serialize_impl(A& in_out, U (&ys)[Len], std::false_type) {
template <class P, class U, size_t Len>
static void array_serialize_impl(P& proc, U (&ys)[Len], std::false_type) {
for (auto& y : ys)
in_out & y;
proc & y;
}
template <class A, class U, size_t Len>
static void array_serialize(A& in_out, U (&ys)[Len]) {
template <class P, class U, size_t Len>
static void array_serialize(P& proc, U (&ys)[Len]) {
std::integral_constant<bool,std::is_array<U>::value> token;
array_serialize_impl(in_out, ys, token);
array_serialize_impl(proc, ys, token);
}
};
......
......@@ -330,17 +330,17 @@ splice(const typed_actor<Xs...>& x, const Ts&... xs) {
}
/// @relates typed_actor
template <class T, class... Ts>
typename std::enable_if<T::is_saving::value>::type
serialize(T& sink, typed_actor<Ts...>& hdl, const unsigned int) {
template <class Processor, class... Ts>
typename std::enable_if<Processor::is_saving::value>::type
serialize(Processor& sink, typed_actor<Ts...>& hdl, const unsigned int) {
auto addr = hdl.address();
sink << addr;
}
/// @relates typed_actor
template <class T, class... Ts>
typename std::enable_if<T::is_loading::value>::type
serialize(T& sink, typed_actor<Ts...>& hdl, const unsigned int) {
template <class Processor, class... Ts>
typename std::enable_if<Processor::is_loading::value>::type
serialize(Processor& sink, typed_actor<Ts...>& hdl, const unsigned int) {
actor_addr addr;
sink >> addr;
hdl = actor_cast<typed_actor<Ts...>>(addr);
......
......@@ -51,8 +51,8 @@ struct unit_t : detail::comparable<unit_t> {
static constexpr unit_t unit = unit_t{};
/// @relates unit_t
template <class T>
void serialize(T&, const unit_t&, const unsigned int) {
template <class Processor>
void serialize(Processor&, const unit_t&, const unsigned int) {
// nop
}
......
......@@ -161,10 +161,10 @@ struct kvstate {
std::unordered_map<key_type, std::pair<mapped_type, subscriber_set>> data;
std::unordered_map<actor,topic_set> subscribers;
const char* name = "caf.config_server";
template <class T>
friend void serialize(T& in_out, kvstate& x, const unsigned int) {
in_out & x.data;
in_out & x.subscribers;
template <class Processor>
friend void serialize(Processor& proc, kvstate& x, const unsigned int) {
proc & x.data;
proc & x.subscribers;
}
};
} // namespace <anonymous>
......
......@@ -39,9 +39,9 @@ struct migratable_state {
const char* migratable_state::name = "migratable_actor";
template <class Archive>
void serialize(Archive& ar, migratable_state& x, const unsigned int) {
ar & x.value;
template <class Processor>
void serialize(Processor& proc, migratable_state& x, const unsigned int) {
proc & x.value;
}
struct migratable_actor : stateful_actor<migratable_state> {
......
......@@ -175,9 +175,9 @@ bool operator==(const s1& lhs, const s1& rhs) {
return true;
}
template <class T>
void serialize(T& in_out, s1& x, const unsigned int) {
in_out & x.value;
template <class Processor>
void serialize(Processor& proc, s1& x, const unsigned int) {
proc & x.value;
}
std::string to_string(const s1& x) {
......@@ -196,9 +196,9 @@ bool operator==(const s2& lhs, const s2& rhs) {
return true;
}
template <class T>
void serialize(T& in_out, s2& x, const unsigned int) {
in_out & x.value;
template <class Processor>
void serialize(Processor& proc, s2& x, const unsigned int) {
proc & x.value;
}
std::string to_string(const s2& x) {
......@@ -216,9 +216,9 @@ bool operator==(const s3& lhs, const s3& rhs) {
return lhs.value == rhs.value;
}
template <class T>
void serialize(T& in_out, s3& x, const unsigned int) {
in_out & x.value;
template <class Processor>
void serialize(Processor& proc, s3& x, const unsigned int) {
proc & x.value;
}
std::string to_string(const s3& x) {
......
......@@ -73,9 +73,9 @@ struct raw_struct {
string str;
};
template <class T>
void serialize(T& in_out, raw_struct& x, const unsigned int) {
in_out & x.str;
template <class Processor>
void serialize(Processor& proc, raw_struct& x, const unsigned int) {
proc & x.str;
}
bool operator==(const raw_struct& lhs, const raw_struct& rhs) {
......@@ -102,10 +102,10 @@ struct test_array {
int value2[2][4];
};
template <class T>
void serialize(T& in_out, test_array& x, const unsigned int) {
in_out & x.value;
in_out & x.value2;
template <class Processor>
void serialize(Processor& proc, test_array& x, const unsigned int) {
proc & x.value;
proc & x.value2;
}
bool operator==(const test_array& lhs, const test_array& rhs) {
......@@ -128,8 +128,8 @@ struct test_empty_non_pod {
}
};
template <class T>
void serialize(T&, test_empty_non_pod&, const unsigned int) {
template <class Processor>
void serialize(Processor&, test_empty_non_pod&, const unsigned int) {
// nop
}
......@@ -152,15 +152,15 @@ struct fixture {
scoped_execution_unit context;
message msg;
template <class IO>
void apply(IO&) {
template <class Processor>
void apply(Processor&) {
// end of recursion
}
template <class IO, class T, class... Ts>
void apply(IO& in_out, T& x, Ts&... xs) {
in_out & x;
apply(in_out, xs...);
template <class Processor, class T, class... Ts>
void apply(Processor& proc, T& x, Ts&... xs) {
proc & x;
apply(proc, xs...);
}
template <class T, class... Ts>
......
......@@ -81,10 +81,10 @@ struct my_request {
int b;
};
template <class T>
void serialize(T& in_out, my_request& x, const unsigned int) {
in_out & x.a;
in_out & x.b;
template <class Processor>
void serialize(Processor& proc, my_request& x, const unsigned int) {
proc & x.a;
proc & x.b;
}
using server_type = typed_actor<replies_to<my_request>::with<bool>>;
......
......@@ -49,9 +49,9 @@ public:
// nop
}
template <class T>
friend void serialize(T& in_out, accept_handle& x, const unsigned int) {
in_out & x.id_;
template <class Procesor>
friend void serialize(Procesor& proc, accept_handle& x, const unsigned int) {
proc & x.id_;
}
private:
......
......@@ -48,15 +48,15 @@ struct header {
};
/// @relates header
template <class T>
void serialize(T& in_or_out, header& hdr, const unsigned int) {
in_or_out & hdr.source_node;
in_or_out & hdr.dest_node;
in_or_out & hdr.source_actor;
in_or_out & hdr.dest_actor;
in_or_out & hdr.payload_len;
in_or_out & hdr.operation;
in_or_out & hdr.operation_data;
template <class Processor>
void serialize(Processor& proc, header& hdr, const unsigned int) {
proc & hdr.source_node;
proc & hdr.dest_node;
proc & hdr.source_actor;
proc & hdr.dest_actor;
proc & hdr.payload_len;
proc & hdr.operation;
proc & hdr.operation_data;
}
/// @relates header
......
......@@ -52,9 +52,10 @@ public:
// nop
}
template <class T>
friend void serialize(T& in_out, connection_handle& x, const unsigned int) {
in_out & x.id_;
template <class Processor>
friend void serialize(Processor& proc, connection_handle& x,
const unsigned int) {
proc & x.id_;
}
private:
......
......@@ -59,10 +59,10 @@ inline bool operator!=(const new_connection_msg& lhs,
}
/// @relates new_connection_msg
template <class T>
void serialize(T& in_out, new_connection_msg& x, const unsigned int) {
in_out & x.source;
in_out & x.handle;
template <class Processor>
void serialize(Processor& proc, new_connection_msg& x, const unsigned int) {
proc & x.source;
proc & x.handle;
}
/// Signalizes newly arrived data for a {@link broker}.
......@@ -93,10 +93,10 @@ inline bool operator!=(const new_data_msg& lhs, const new_data_msg& rhs) {
}
/// @relates new_data_msg
template <class T>
void serialize(T& in_out, new_data_msg& x, const unsigned int) {
in_out & x.handle;
in_out & x.buf;
template <class Processor>
void serialize(Processor& proc, new_data_msg& x, const unsigned int) {
proc & x.handle;
proc & x.buf;
}
/// Signalizes that a certain amount of bytes has been written.
......@@ -131,11 +131,11 @@ inline bool operator!=(const data_transferred_msg& x,
}
/// @relates new_data_msg
template <class T>
void serialize(T& in_out, data_transferred_msg& x, const unsigned int) {
in_out & x.handle;
in_out & x.written;
in_out & x.remaining;
template <class Processor>
void serialize(Processor& proc, data_transferred_msg& x, const unsigned int) {
proc & x.handle;
proc & x.written;
proc & x.remaining;
}
/// Signalizes that a {@link broker} connection has been closed.
......@@ -161,9 +161,9 @@ inline bool operator!=(const connection_closed_msg& lhs,
}
/// @relates connection_closed_msg
template <class T>
void serialize(T& in_out, connection_closed_msg& x, const unsigned int) {
in_out & x.handle;
template <class Processor>
void serialize(Processor& proc, connection_closed_msg& x, const unsigned int) {
proc & x.handle;
}
/// Signalizes that a {@link broker} acceptor has been closed.
......@@ -185,9 +185,9 @@ inline bool operator!=(const acceptor_closed_msg& lhs,
}
/// @relates acceptor_closed_msg
template <class T>
void serialize(T& in_out, acceptor_closed_msg& x, const unsigned int) {
in_out & x.handle;
template <class Processor>
void serialize(Processor& proc, acceptor_closed_msg& x, const unsigned int) {
proc & x.handle;
}
} // namespace io
......
......@@ -39,9 +39,9 @@ struct ping {
int32_t value;
};
template <class T>
void serialize(T& in_or_out, ping& x, const unsigned int) {
in_or_out & x.value;
template <class Processor>
void serialize(Processor& proc, ping& x, const unsigned int) {
proc & x.value;
}
bool operator==(const ping& lhs, const ping& rhs) {
......@@ -52,9 +52,9 @@ struct pong {
int32_t value;
};
template <class T>
void serialize(T& in_or_out, pong& x, const unsigned int) {
in_or_out & x.value;
template <class Processor>
void serialize(Processor& proc, pong& x, const unsigned int) {
proc & x.value;
}
bool operator==(const pong& lhs, const pong& rhs) {
......
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