2016-12-03 17:44:09 +00:00
|
|
|
#pragma once
|
|
|
|
#include <type_traits>
|
|
|
|
#include "chat_messages.hpp"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* SFINAE compile-type checker for receive policies (as defined in chat_networking.hpp)
|
|
|
|
* it checks whether PolicyCandidate supplies all of the following methods:
|
2016-12-04 11:51:28 +00:00
|
|
|
* - static void message_do_what(chat_message)
|
|
|
|
* - static void handshake_do_what(chat_message)
|
|
|
|
* - static void serverdirection_do_what(chat_message)
|
|
|
|
* - static void login_do_what(chat_message)
|
2016-12-05 11:57:57 +00:00
|
|
|
* - static void logout_do_what(chat_message)
|
|
|
|
* - static void invalid_msg_do_what(chat_message) */
|
2016-12-03 17:44:09 +00:00
|
|
|
template <class PolicyCandidate, typename = void>
|
2016-12-04 13:31:26 +00:00
|
|
|
struct is_valid_receive_policy : std::false_type {};
|
2016-12-03 17:44:09 +00:00
|
|
|
|
|
|
|
template <class PolicyCandidate>
|
2016-12-04 13:31:26 +00:00
|
|
|
struct is_valid_receive_policy<
|
2016-12-03 17:44:09 +00:00
|
|
|
PolicyCandidate,
|
|
|
|
typename
|
|
|
|
std::enable_if<
|
|
|
|
std::is_same<
|
|
|
|
decltype(PolicyCandidate
|
|
|
|
::message_do_what(std::declval<chat::chat_message>())),
|
|
|
|
void
|
|
|
|
>::value
|
2016-12-03 22:27:36 +00:00
|
|
|
&&
|
|
|
|
std::is_same<
|
|
|
|
decltype(PolicyCandidate
|
|
|
|
::handshake_do_what(std::declval<chat::chat_message>())),
|
|
|
|
void
|
|
|
|
>::value
|
2016-12-04 11:51:28 +00:00
|
|
|
&&
|
|
|
|
std::is_same<
|
|
|
|
decltype(PolicyCandidate
|
|
|
|
::serverdirection_do_what(std::declval<chat::chat_message>())),
|
|
|
|
void
|
|
|
|
>::value
|
|
|
|
&&
|
|
|
|
std::is_same<
|
|
|
|
decltype(PolicyCandidate
|
|
|
|
::login_do_what(std::declval<chat::chat_message>())),
|
|
|
|
void
|
|
|
|
>::value
|
|
|
|
&&
|
|
|
|
std::is_same<
|
|
|
|
decltype(PolicyCandidate
|
|
|
|
::logout_do_what(std::declval<chat::chat_message>())),
|
|
|
|
void
|
|
|
|
>::value
|
2016-12-05 11:57:57 +00:00
|
|
|
&&
|
|
|
|
std::is_same<
|
|
|
|
decltype(PolicyCandidate
|
|
|
|
::invalid_msg_do_what(std::declval<chat::chat_message>())),
|
|
|
|
void
|
|
|
|
>::value
|
2016-12-03 17:44:09 +00:00
|
|
|
>::type>
|
2016-12-04 13:31:26 +00:00
|
|
|
: std::true_type {};
|
|
|
|
|
|
|
|
|
|
|
|
/* SFINAE compile-type checker for send policies (as defined in chat_networking.hpp)
|
|
|
|
* it checks whether PolicyCandidate supplies all of the following methods:
|
|
|
|
* - static bool check_msg_length(chat_message) */
|
|
|
|
template <class PolicyCandidate, typename = void>
|
|
|
|
struct is_valid_send_policy : std::false_type {};
|
|
|
|
|
|
|
|
template <class PolicyCandidate>
|
|
|
|
struct is_valid_send_policy<
|
|
|
|
PolicyCandidate,
|
|
|
|
typename
|
|
|
|
std::enable_if<
|
|
|
|
std::is_same<
|
|
|
|
decltype(PolicyCandidate
|
|
|
|
::check_msg_length(std::declval<chat::chat_message>())),
|
|
|
|
bool
|
|
|
|
>::value
|
|
|
|
>::type>
|
2016-12-03 17:44:09 +00:00
|
|
|
: std::true_type {};
|