soccer_role.cpp 2.9 KB
Newer Older
Matthew Hausknecht's avatar
Matthew Hausknecht committed
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 48 49 50 51 52 53 54 55 56 57 58
// -*-c++-*-

/*!
  \file soccer_role.cpp
  \brief abstract player role class Header File
*/

/*
 *Copyright:

  Copyright (C) Hidehisa AKIYAMA

  This code is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 3, or (at your option)
  any later version.

  This code is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this code; see the file COPYING.  If not, write to
  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

 *EndCopyright:
 */

/////////////////////////////////////////////////////////////////////

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include "soccer_role.h"

// #include "role_sample.h"
// #include "role_savior.h"
// #include "role_goalie.h"
// #include "role_center_back.h"
// #include "role_center_forward.h"
// #include "role_defensive_half.h"
// #include "role_offensive_half.h"
// #include "role_side_back.h"
// #include "role_side_forward.h"
// #include "role_sweeper.h"

#include <rcsc/player/world_model.h>
#include <rcsc/game_mode.h>

/*-------------------------------------------------------------------*/
/*!

*/
SoccerRole::Creators &
SoccerRole::creators()
{
59
    static thread_local Creators s_instance;
Matthew Hausknecht's avatar
Matthew Hausknecht committed
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
    return s_instance;
}

/*-------------------------------------------------------------------*/
/*!

*/
SoccerRole::Ptr
SoccerRole::create( const std::string & name )
{
    SoccerRole::Ptr ptr( static_cast< SoccerRole * >( 0 ) );

    Creator creator;
    if ( SoccerRole::creators().getCreator( creator, name ) )
    {
        ptr = creator();
    }
    // else if ( RoleSample::NAME == name ) ptr = RoleSample::create();
    // else if ( RoleGoalie::NAME == name ) ptr = RoleGoalie::create();
    // else if ( RoleSavior::NAME == name ) ptr = RoleSavior::create();
    // else if ( RoleCenterBack::NAME == name ) ptr = RoleCenterBack::create();
    // else if ( RoleCenterForward::NAME == name ) ptr = RoleCenterForward::create();
    // else if ( RoleDefensiveHalf::NAME == name ) ptr = RoleDefensiveHalf::create();
    // else if ( RoleOffensiveHalf::NAME == name ) ptr = RoleOffensiveHalf::create();
    // else if ( RoleSideBack::NAME == name ) ptr = RoleSideBack::create();
    // else if ( RoleSideForward::NAME == name ) ptr = RoleSideForward::create();
    // else if ( RoleSweeper::NAME == name ) ptr = RoleSideSweeper::create();

    return ptr;
}


/*-------------------------------------------------------------------*/
/*!

*/
bool
SoccerRole::acceptExecution( const rcsc::WorldModel & wm )
{
    if ( wm.gameMode().type() == rcsc::GameMode::PlayOn )
    {
        return true;
    }

    return false;
}