-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatic_multicommand_parallel.h
47 lines (44 loc) · 1.96 KB
/
static_multicommand_parallel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// (C) Copyright 2009-2011 Vit Kasal
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#pragma once
#include "static_command.h"
namespace si
{
template<typename commands, bool no_commands = boost::mpl::empty<commands>::value>class static_multicommand_parallel_base
: public boost::mpl::front<commands>::type
, public static_multicommand_parallel_base<typename boost::mpl::pop_front<commands>::type>
{
public:
typedef boost::mpl::front<commands>::type prefered_command_base;
typedef public static_multicommand_parallel_base<typename boost::mpl::pop_front<commands>::type> alternate_commands;
inline static void write(command_interface::writer_type writer, protocols::id<>::value_type protocol)
{
return prefered_command_base::allowed_for_protocol(protocol)? prfered_command::write(writer, protocol): alternate_commands::write(writer, protocol);
}
inline static std::size_t size(protocols::id<>::value_type protocol)
{
return prefered_command_base::allowed_for_protocol(protocol)? prfered_command::size(protocol): alternate_commands::write(protocol);
}
inline static bool allowed_for_protocol(protocols::id<>::value_type protocol)
{
return prefered_command_base::allowed_for_protocol(protocol)? true: alternate_commands::allowed_for_protocol(protocol);
}
};
template<typename commands>class static_multicommand_parallel_base<commands, true>
{
inline static void write(command_interface::writer_type writer, protocols::id<>::value_type protocol)
{
throw std::invalid_argument("si::command::write::incorrect_protocol");
}
inline static std::size_t size(protocols::id<>::value_type protocol)
{
throw std::invalid_argument("si::command::size::incorrect_protocol");
}
inline static bool allowed_for_protocol(protocols::id<>::value_type protocol)
{
return false;
}
}
}//namespace si