LIBRCSC Docs
Documentation for HELIOS's BASE LIBRCSC library for RoboCup 2D Simulation League.
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
role_type.h
Go to the documentation of this file.
1// -*-c++-*-
2
8/*
9 *Copyright:
10
11 Copyright (C) Hidehisa AKIYAMA
12
13 This code is free software; you can redistribute it and/or
14 modify it under the terms of the GNU Lesser General Public
15 License as published by the Free Software Foundation; either
16 version 3 of the License, or (at your option) any later version.
17
18 This library is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 Lesser General Public License for more details.
22
23 You should have received a copy of the GNU Lesser General Public
24 License along with this library; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
27 *EndCopyright:
28 */
29
31
32#ifndef RCSC_COMMON_ROLE_TYPE_H
33#define RCSC_COMMON_ROLE_TYPE_H
34
35#include <string>
36
37namespace rcsc {
38
43class RoleType {
44public:
49 enum Type {
50 Goalie = 0,
51 Defender,
52 MidFielder,
53 Forward,
54 Unknown,
55 };
56
61 enum Side {
62 Center = 0,
63 Left = -1,
64 Right = 1,
65 };
66
67private:
68
69 Type M_type;
70 Side M_side; //< role position type
71
72public:
73
78 : M_type( Unknown ),
79 M_side( Center )
80 { }
81
87 RoleType( const Type t,
88 const Side s )
89 : M_type( t ),
90 M_side( s )
91 { }
92
97 void setType( Type t ) { M_type = t; }
98
103 void setSide( Side s ) { M_side = s; }
104
109 Type type() const { return M_type; }
110
115 Side side() const { return M_side; }
116
121 bool isGoalie() const { return M_type == Goalie; }
122
127 bool isDefender() const { return M_type == Defender; }
128
133 bool isMidFielder() const { return M_type == MidFielder; }
134
139 bool isForward() const { return M_type == Forward; }
140
145 bool isCenter() const { return M_side == Center; }
146
151 bool isLeft() const { return M_side == Left; }
152
157 bool isRight() const { return M_side == Right; }
158
163 static std::string to_string( const Type t );
164
169 static std::string to_string( const Side s );
170
175 static Type to_type( const std::string & str );
176
181 static Side to_side( const std::string & str );
182
183};
184
185}
186
187#endif
player's role type information class
Definition: role_type.h:43
bool isDefender() const
check if defender type or not
Definition: role_type.h:127
void setSide(Side s)
set the side type
Definition: role_type.h:103
static std::string to_string(const Side s)
create a string value corresponding to the given side type
Type type() const
get the role type
Definition: role_type.h:109
RoleType()
default constructor
Definition: role_type.h:77
Side
position type (y position)
Definition: role_type.h:61
bool isCenter() const
check if center type or not
Definition: role_type.h:145
bool isForward() const
check if forward type or not
Definition: role_type.h:139
bool isRight() const
check if right type or not
Definition: role_type.h:157
RoleType(const Type t, const Side s)
create with given values
Definition: role_type.h:87
Side side() const
get the side type
Definition: role_type.h:115
bool isGoalie() const
check if goalie type or not
Definition: role_type.h:121
bool isMidFielder() const
check if midfielder type or not
Definition: role_type.h:133
static Side to_side(const std::string &str)
create a side type value from the given string.
Type
role type
Definition: role_type.h:49
bool isLeft() const
check if left type or not
Definition: role_type.h:151
static std::string to_string(const Type t)
create a string value corresponding to the given role type
void setType(Type t)
set the role type
Definition: role_type.h:97
static Type to_type(const std::string &str)
create a role type value from the given string.