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

soccerinput.cpp

Go to the documentation of this file.
00001 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*-
00002    this file is part of rcssserver3D
00003    Fri May 9 2003
00004    Copyright (C) 2003 Koblenz University
00005    $Id: soccerinput.cpp,v 1.1 2004/12/31 11:30:30 rollmark Exp $
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; version 2 of the License.
00010 
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014    GNU General Public License for more details.
00015 
00016    You should have received a copy of the GNU General Public License
00017    along with this program; if not, write to the Free Software
00018    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019 */
00020 #include "soccerinput.h"
00021 #include <zeitgeist/scriptserver/scriptserver.h>
00022 #include <zeitgeist/logserver/logserver.h>
00023 
00024 using namespace boost;
00025 using namespace zeitgeist;
00026 using namespace oxygen;
00027 using namespace kerosin;
00028 
00029 SoccerInput::SoccerInput()
00030 {
00031 }
00032 
00033 SoccerInput::~SoccerInput()
00034 {
00035 }
00036 
00037 void SoccerInput::OnLink()
00038 {
00039     shared_ptr<ScriptServer> scriptServer = GetCore()->GetScriptServer();
00040     scriptServer->CreateVariable("Command.KickOff", CmdKickOff);
00041 
00042     mMonitorClient = shared_dynamic_cast<NetClient>
00043         (GetCore()->Get("/sys/server/simulation/SparkMonitorClient"));
00044 
00045     if (mMonitorClient.get() == 0)
00046         {
00047             GetLog()->Error()
00048                 << "ERROR: (SoccerInput) Unable to get SparkMonitorClient\n";
00049         }
00050 }
00051 
00052 void SoccerInput::OnUnlink()
00053 {
00054     mMonitorClient.reset();
00055 }
00056 
00057 void SoccerInput::SendCommand(const std::string& cmd)
00058 {
00059     if (mMonitorClient.get() == 0)
00060         {
00061             return;
00062         }
00063 
00064     mMonitorClient->SendMessage(cmd);
00065 }
00066 
00067 void SoccerInput::ProcessInput(const InputServer::Input& input)
00068 {
00069     switch (input.id)
00070         {
00071         default:
00072             return;
00073 
00074         case CmdKickOff:
00075             if (input.KeyPress())
00076                 {
00077                     SendCommand("(kickOff)");
00078                 }
00079             break;
00080         };
00081 }

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