Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

soccerbase.h

Go to the documentation of this file.
00001 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*-
00002 
00003    this file is part of rcssserver3D
00004    Fri May 9 2003
00005    Copyright (C) 2002,2003 Koblenz University
00006    Copyright (C) 2003 RoboCup Soccer Server 3D Maintenance Group
00007    $Id: soccerbase.h,v 1.6 2005/12/13 20:55:09 rollmark Exp $
00008 
00009    This program is free software; you can redistribute it and/or modify
00010    it under the terms of the GNU General Public License as published by
00011    the Free Software Foundation; version 2 of the License.
00012 
00013    This program is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016    GNU General Public License for more details.
00017 
00018    You should have received a copy of the GNU General Public License
00019    along with this program; if not, write to the Free Software
00020    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00021 */
00022 #ifndef SOCCERBASE_H
00023 #define SOCCERBASE_H
00024 
00025 #include <soccer/soccertypes.h>
00026 #include <zeitgeist/scriptserver/scriptserver.h>
00027 #include <boost/shared_ptr.hpp>
00028 
00029 namespace zeitgeist
00030 {
00031     class Leaf;
00032 }
00033 
00034 namespace oxygen
00035 {
00036     class SceneServer;
00037     class Scene;
00038     class Transform;
00039     class Perceptor;
00040     class Body;
00041     class SphereCollider;
00042     class ControlAspect;
00043 }
00044 
00045 namespace salt
00046 {
00047     class Vector3f;
00048 }
00049 
00050 class AgentState;
00051 class GameStateAspect;
00052 class SoccerRuleAspect;
00053 class Ball;
00054 
00055 class SoccerBase
00056 {
00057 public:
00058     typedef std::list<boost::shared_ptr<AgentState> > TAgentStateList;
00059 
00060 public:
00061     SoccerBase() {}
00062 
00063     virtual ~SoccerBase() {}
00064 
00066     static bool
00067     GetSceneServer(const zeitgeist::Leaf& base,
00068                    boost::shared_ptr<oxygen::SceneServer>& scene_server);
00069 
00072     static bool
00073     GetTransformParent(const zeitgeist::Leaf& base,
00074                        boost::shared_ptr<oxygen::Transform>& transform_parent);
00075 
00078     static bool
00079     GetBody(const zeitgeist::Leaf& base, boost::shared_ptr<oxygen::Body>& body);
00080 
00083     static bool
00084     GetAgentBody(const boost::shared_ptr<oxygen::Transform> transform,
00085                  boost::shared_ptr<oxygen::Body>& agent_body);
00086 
00089     static bool
00090     GetAgentBody(const zeitgeist::Leaf& base, TTeamIndex idx,
00091                  int unum, boost::shared_ptr<oxygen::Body>& agent_body);
00092 
00095     static bool
00096     GetAgentState(const zeitgeist::Leaf& base,
00097                   boost::shared_ptr<AgentState>& agent_state);
00098 
00101     static bool
00102     GetAgentState(const boost::shared_ptr<oxygen::Transform> transform,
00103                   boost::shared_ptr<AgentState>& agentState);
00104 
00107     static bool
00108     GetAgentState(const zeitgeist::Leaf& base, TTeamIndex idx,
00109                  int unum, boost::shared_ptr<AgentState>& agent_state);
00110 
00111     static bool
00112     GetAgentStates(const zeitgeist::Leaf& base,
00113                    TAgentStateList& agentStates,
00114                    TTeamIndex idx = TI_NONE);
00115 
00117     static bool
00118     GetGameState(const zeitgeist::Leaf& base,
00119                  boost::shared_ptr<GameStateAspect>& game_state);
00120 
00122     static bool
00123     GetSoccerRuleAspect(const zeitgeist::Leaf& base,
00124                         boost::shared_ptr<SoccerRuleAspect>& soccer_rule_aspect);
00125 
00127     static bool
00128     GetActiveScene(const zeitgeist::Leaf& base,
00129                    boost::shared_ptr<oxygen::Scene>& active_scene);
00130 
00132     static bool
00133     GetBall(const zeitgeist::Leaf& base, boost::shared_ptr<Ball>& ball);
00134 
00136     static bool
00137     GetBallBody(const zeitgeist::Leaf& base,
00138                 boost::shared_ptr<oxygen::Body>& body);
00139 
00141     static bool
00142     GetBallCollider(const zeitgeist::Leaf& base,
00143                 boost::shared_ptr<oxygen::SphereCollider>& sphere);
00144 
00146     static salt::Vector3f FlipView(const salt::Vector3f& pos, TTeamIndex ti);
00147 
00149     static TTeamIndex OpponentTeam(TTeamIndex ti);
00150 
00153     static boost::shared_ptr<oxygen::ControlAspect>
00154     GetControlAspect(const zeitgeist::Leaf& base, const std::string& name);
00155 
00157     template<typename TYPE>
00158     static bool GetSoccerVar(const zeitgeist::Leaf& base, const std::string& name,
00159                       TYPE& value)
00160     {
00161         static const std::string nSpace = "Soccer.";
00162         bool ok = base.GetCore()->GetScriptServer()->GetVariable
00163             (std::string(nSpace + name),value);
00164 
00165         if (! ok)
00166             {
00167                 base.GetLog()->Error()
00168                     << "ERROR: (SoccerBase: " << base.GetName()
00169                     << ") soccer variable '" << name << "' not found\n";
00170                 return false;
00171             }
00172 
00173         return ok;
00174     }
00175 
00177     static std::string PlayMode2Str(const TPlayMode mode);
00178 };
00179 
00180 #endif

Generated on Thu Apr 6 15:25:40 2006 for rcssserver3d by  doxygen 1.4.4