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

spadesactevent.cpp

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: spadesactevent.cpp,v 1.3 2004/02/12 14:07:23 fruit 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 #include "spadesactevent.h"
00023 #include "spadesserver.h"
00024 #include <zeitgeist/logserver/logserver.h>
00025 #include <oxygen/gamecontrolserver/gamecontrolserver.h>
00026 #include <oxygen/agentaspect/agentaspect.h>
00027 
00028 using namespace oxygen;
00029 using namespace zeitgeist;
00030 using namespace boost;
00031 using namespace std;
00032 
00033 void SpadesActEvent::Print (std::ostream & /*o*/) const
00034 {
00035 }
00036 
00037 bool SpadesActEvent::realizeEventWorldModel(spades::WorldModel* pWM)
00038 {
00039   // we can't create a shared_ptr to the SpadesServer here, as this
00040   // shared_ptr wouldn't know of other shared_ptrs to the
00041   // SpadesServer
00042   SpadesServer* spadesServer = dynamic_cast<SpadesServer*>(pWM);
00043 
00044   if (spadesServer == NULL)
00045         {
00046           // we can't use the LogServer here :(
00047           return false;
00048         }
00049 
00050   shared_ptr<GameControlServer> gcs = spadesServer->GetGameControlServer();
00051   if (gcs.get() == 0)
00052       {
00053           spadesServer->GetLog()->Error()
00054               << "(SpadesActEvent) GameControlServer not found." << endl;
00055           return false;
00056       }
00057 
00058   // lookup the AgentAspect
00059   int id = getAgent();
00060   shared_ptr<AgentAspect> agent = gcs->GetAgentAspect(id);
00061 
00062   if (agent.get() == 0)
00063       {
00064           spadesServer->GetLog()->Warning()
00065               << "ERROR: (SpadesActEvent) no AgentAspect for id " << id
00066               << "found." << endl;
00067           return false;
00068       }
00069 
00070   // realize the stored actions
00071   agent->RealizeActions(mActionList);
00072 
00073   // indicate that we 'did something' with the event
00074   return true;
00075 }

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