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