Commit 5b1834de authored by Dominik Charousset's avatar Dominik Charousset

Move abstract_uniform_type_info to public API

The class abstract_uniform_type_info is the recommended way of implementing
user-defined serialization classes and is even highlighted in one of the
examples. Hence, it belongs to the public API.
parent 5cd516c6
......@@ -86,9 +86,9 @@ bool operator==(const tree& lhs, const tree& rhs) {
// - does have a default constructor
// - does have a copy constructor
// - does provide operator==
class tree_type_info : public detail::abstract_uniform_type_info<tree> {
class tree_type_info : public abstract_uniform_type_info<tree> {
public:
tree_type_info() : detail::abstract_uniform_type_info<tree>("tree") {
tree_type_info() : abstract_uniform_type_info<tree>("tree") {
// nop
}
......
......@@ -17,8 +17,8 @@
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#ifndef CAF_DETAIL_ABSTRACT_UNIFORM_TYPE_INFO_HPP
#define CAF_DETAIL_ABSTRACT_UNIFORM_TYPE_INFO_HPP
#ifndef CAF_ABSTRACT_UNIFORM_TYPE_INFO_HPP
#define CAF_ABSTRACT_UNIFORM_TYPE_INFO_HPP
#include "caf/message.hpp"
#include "caf/deserializer.hpp"
......@@ -26,10 +26,7 @@
#include "caf/detail/type_traits.hpp"
#include "caf/detail/uniform_type_info_map.hpp"
namespace caf {
namespace detail {
/// Implements all pure virtual functions of `uniform_type_info`
/// except serialize() and deserialize().
......@@ -104,7 +101,6 @@ private:
}
};
} // namespace detail
} // namespace caf
#endif // CAF_DETAIL_ABSTRACT_UNIFORM_TYPE_INFO_HPP
#endif // CAF_ABSTRACT_UNIFORM_TYPE_INFO_HPP
......@@ -27,8 +27,7 @@
#include "caf/config.hpp"
#include "caf/uniform_type_info.hpp"
#include "caf/detail/abstract_uniform_type_info.hpp"
#include "caf/abstract_uniform_type_info.hpp"
#include "caf/detail/safe_equal.hpp"
#include "caf/detail/type_traits.hpp"
......@@ -78,7 +77,7 @@ const uniform_type_info* announce(const std::type_info& tinfo,
/// whereas `xs` are the "sub-members" of `Member`.
/// @see {@link announce_4.cpp announce example 4}
template <class Member, class Parent, class... Ts>
std::pair<Member Parent::*, detail::abstract_uniform_type_info<Member>*>
std::pair<Member Parent::*, abstract_uniform_type_info<Member>*>
compound_member(Member Parent::*memptr, const Ts&... xs) {
return {memptr, new detail::default_uniform_type_info<Member>("???", xs...)};
}
......@@ -89,7 +88,7 @@ compound_member(Member Parent::*memptr, const Ts&... xs) {
/// whereas `xs` are the "sub-members" of `Member`.
/// @see {@link announce_4.cpp announce example 4}
template <class Member, class Parent, class... Ts>
std::pair<Member& (Parent::*)(), detail::abstract_uniform_type_info<Member>*>
std::pair<Member& (Parent::*)(), abstract_uniform_type_info<Member>*>
compound_member(Member& (Parent::*getter)(), const Ts&... xs) {
return {getter, new detail::default_uniform_type_info<Member>("???", xs...)};
}
......@@ -101,7 +100,7 @@ compound_member(Member& (Parent::*getter)(), const Ts&... xs) {
/// @see {@link announce_4.cpp announce example 4}
template <class Parent, class GRes, class SRes, class SArg, class... Ts>
std::pair<std::pair<GRes (Parent::*)() const, SRes (Parent::*)(SArg)>,
detail::abstract_uniform_type_info<typename std::decay<GRes>::type>*>
abstract_uniform_type_info<typename std::decay<GRes>::type>*>
compound_member(const std::pair<GRes (Parent::*)() const,
SRes (Parent::*)(SArg)>& gspair,
const Ts&... xs) {
......
......@@ -28,10 +28,9 @@
#include "caf/serializer.hpp"
#include "caf/typed_actor.hpp"
#include "caf/deserializer.hpp"
#include "caf/abstract_uniform_type_info.hpp"
#include "caf/detail/type_traits.hpp"
#include "caf/detail/abstract_uniform_type_info.hpp"
namespace caf {
namespace detail {
......@@ -251,9 +250,9 @@ template <class T, class AccessPolicy,
class SerializePolicy = default_serialize_policy,
bool IsEnum = std::is_enum<T>::value,
bool IsEmptyType = std::is_class<T>::value&& std::is_empty<T>::value>
class member_tinfo : public detail::abstract_uniform_type_info<T> {
class member_tinfo : public abstract_uniform_type_info<T> {
public:
using super = detail::abstract_uniform_type_info<T>;
using super = abstract_uniform_type_info<T>;
member_tinfo(AccessPolicy apol, SerializePolicy spol)
: super("--member--"),
apol_(std::move(apol)), spol_(std::move(spol)) {
......@@ -298,9 +297,9 @@ private:
template <class T, class A, class S>
class member_tinfo<T, A, S, false, true>
: public detail::abstract_uniform_type_info<T> {
: public abstract_uniform_type_info<T> {
public:
using super = detail::abstract_uniform_type_info<T>;
using super = abstract_uniform_type_info<T>;
member_tinfo(const A&, const S&) : super("--member--") {
// nop
......@@ -325,9 +324,9 @@ public:
template <class T, class AccessPolicy, class SerializePolicy>
class member_tinfo<T, AccessPolicy, SerializePolicy, true, false>
: public detail::abstract_uniform_type_info<T> {
: public abstract_uniform_type_info<T> {
public:
using super = detail::abstract_uniform_type_info<T>;
using super = abstract_uniform_type_info<T>;
using value_type = typename std::underlying_type<T>::type;
member_tinfo(AccessPolicy apol, SerializePolicy spol)
......@@ -476,9 +475,9 @@ uniform_type_info_ptr new_member_tinfo(GRes (C::*getter)() const,
}
template <class T>
class default_uniform_type_info : public detail::abstract_uniform_type_info<T> {
class default_uniform_type_info : public abstract_uniform_type_info<T> {
public:
using super = detail::abstract_uniform_type_info<T>;
using super = abstract_uniform_type_info<T>;
template <class... Ts>
default_uniform_type_info(std::string tname, Ts&&... xs)
......@@ -540,7 +539,7 @@ private:
// pr.second = meta object to handle pr.first
template <class R, class C, class... Ts>
void push_back(const std::pair<R C::*,
detail::abstract_uniform_type_info<R>*>& pr,
abstract_uniform_type_info<R>*>& pr,
Ts&&... xs) {
members_.push_back(new_member_tinfo(pr.first,
uniform_type_info_ptr(pr.second)));
......@@ -563,7 +562,7 @@ private:
void push_back(const std::pair<
std::pair<GR (C::*)() const,
SR (C::*)(ST)>,
detail::abstract_uniform_type_info<
abstract_uniform_type_info<
typename std::decay<GR>::type>*
>& pr,
Ts&&... xs) {
......@@ -577,9 +576,9 @@ private:
template <class... Sigs>
class default_uniform_type_info<typed_actor<Sigs...>> :
public detail::abstract_uniform_type_info<typed_actor<Sigs...>> {
public abstract_uniform_type_info<typed_actor<Sigs...>> {
public:
using super = detail::abstract_uniform_type_info<typed_actor<Sigs...>>;
using super = abstract_uniform_type_info<typed_actor<Sigs...>>;
using handle_type = typed_actor<Sigs...>;
default_uniform_type_info(std::string tname) : super(std::move(tname)) {
......
......@@ -58,13 +58,13 @@
#include "caf/binary_serializer.hpp"
#include "caf/binary_deserializer.hpp"
#include "caf/await_all_actors_done.hpp"
#include "caf/abstract_uniform_type_info.hpp"
#include "caf/detail/ieee_754.hpp"
#include "caf/detail/int_list.hpp"
#include "caf/detail/safe_equal.hpp"
#include "caf/detail/type_traits.hpp"
#include "caf/detail/get_mac_addresses.hpp"
#include "caf/detail/abstract_uniform_type_info.hpp"
using namespace std;
using namespace caf;
......@@ -81,8 +81,8 @@ bool operator==(const raw_struct& lhs, const raw_struct& rhs) {
return lhs.str == rhs.str;
}
struct raw_struct_type_info : detail::abstract_uniform_type_info<raw_struct> {
using super = detail::abstract_uniform_type_info<raw_struct>;
struct raw_struct_type_info : abstract_uniform_type_info<raw_struct> {
using super = abstract_uniform_type_info<raw_struct>;
raw_struct_type_info() : super("raw_struct") {
// nop
}
......
......@@ -117,9 +117,9 @@ deserialize_impl(T& dm, deserializer* source) {
}
template <class T>
class uti_impl : public detail::abstract_uniform_type_info<T> {
class uti_impl : public abstract_uniform_type_info<T> {
public:
using super = detail::abstract_uniform_type_info<T>;
using super = abstract_uniform_type_info<T>;
explicit uti_impl(const char* tname) : super(tname) {
// nop
......
......@@ -39,6 +39,7 @@
#include "caf/io/all.hpp"
#include "caf/detail/type_nr.hpp"
#include "caf/detail/uniform_type_info_map.hpp"
using std::cout;
using std::endl;
......
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