2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@gmail.com>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
14 #include <boost/shared_ptr.hpp>
16 #pragma warning( push )
17 #pragma warning( disable : 4100 )
18 #include <boost/variant.hpp>
19 #pragma warning( pop )
21 #include <boost/variant.hpp>
23 #include "varianttraits.h"
26 template <typename Pos
>
27 class ChessServerInfo
{
29 boost::shared_ptr
<Pos
> position
;
30 ChessServerInfo(const boost::shared_ptr
<Pos
> position
)
31 : position(position
) { }
34 template <typename Pos
>
35 class PoolServerInfo
{
38 typename PoolTraits
<Pos
>::type
,
39 PoolTraits
<Pos
>::number
>::type pools
;
42 template <typename Pos
>
44 typedef boost::variant
<ChessServerInfo
<Pos
>, PoolServerInfo
<Pos
> > type
;
50 template <typename Pos
> class ServerInfoVisitor
;
52 template <typename Pos
>
55 virtual void apply(ServerInfoVisitor
<Pos
>& visitor
) const = 0;
58 template<typename Pos
> class ChessServerInfo
;
59 template<typename Pos
> class PoolServerInfo
;
61 template <typename Pos
>
62 class ServerInfoVisitor
{
64 virtual void visit(const ChessServerInfo
<Pos
>& info
) = 0;
65 virtual void visit(const PoolServerInfo
<Pos
>& info
) = 0;
69 template <typename Pos
>
70 class ChessServerInfo
: public ServerInfo
<Pos
> {
72 boost::shared_ptr
<Pos
> position
;
73 virtual void apply(ServerInfoVisitor
<Pos
>& visitor
) const {
76 ChessServerInfo(const boost::shared_ptr
<Pos
> position
)
77 : position(position
) { }
80 template <typename Pos
>
81 class PoolServerInfo
: public ServerInfo
<Pos
> {
83 typename PoolTraits
<Pos
>::type pools
[PoolTraits
<Pos
>::number
];
84 virtual void apply(ServerInfoVisitor
<Pos
>& visitor
) const {
91 #endif // SERVERINFO_H