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

spadesserver.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: spadesserver.h,v 1.9 2004/04/23 13:27:59 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 #ifndef OXYGEN_SPADESSERVER_H
00023 #define OXYGEN_SPADESSERVER_H
00024 
00025 #include <spades/enginemain.hpp>
00026 #include <spades/SimEngine.hpp>
00027 #include <zeitgeist/class.h>
00028 #include <zeitgeist/node.h>
00029 #include "paramreader.h"
00030 #include <queue>
00031 
00032 namespace oxygen
00033 {
00034 class GameControlServer;
00035 class MonitorServer;
00036 class SceneServer;
00037 
00040 class SpadesServer :
00041         public zeitgeist::Node,
00042         public spades::WorldModel
00043 {
00044 public:
00045     SpadesServer();
00046     ~SpadesServer();
00047 
00048     // Methods starting with small letters are SPADES interface methods.
00049     // Methods with a initial capital letter are additional methods needed
00050     // for the zeitgeist framework.
00051 
00054     virtual bool ConstructInternal();
00055 
00057     virtual void OnLink();
00058 
00060     virtual void OnUnlink();
00061 
00063     boost::shared_ptr<GameControlServer> GetGameControlServer() const;
00064 
00068     float GetTimePerStep() const;
00069 
00073     bool GetRunIntegratedCommserver() const;
00074 
00080     int GetCommServersWanted() const;
00081 
00085     int GetMonitorInterval() const;
00086 
00088     bool GetSendAgentThinkTimes() const;
00089 
00094     void QueueAgents(const std::string& agentType="default", int num=1);
00095 
00097     void Unpause();
00098 
00100     virtual void UpdateCached();
00101 
00102     // ----------------------------------------------------------------------
00103     // SPADES interface methods start here
00104 
00108     spades::EngineParam* parseParameters(int argc, const char* const *argv);
00109 
00117     bool initialize(spades::SimEngine* pSE);
00118 
00120     spades::SimEngine* GetSimEngine();
00121 
00123     bool finalize();
00124 
00136     spades::SimTime
00137     simToTime(spades::SimTime time_curr, spades::SimTime time_desired);
00138 
00147     spades::DataArray getMonitorHeaderInfo();
00148 
00154     spades::DataArray getMonitorInfo(spades::SimTime time);
00155 
00163     void parseMonitorMessage(const char* data, unsigned datalen);
00164 
00170     spades::SimTime getMinActionLatency() const;
00171 
00176     spades::SimTime getMinSenseLatency() const;
00177 
00185     spades::ActEvent*
00186     parseAct(spades::SimTime t, spades::AgentID a, const char* data, unsigned datalen) const;
00187 
00192     void pauseModeCallback();
00193 
00198     bool agentConnect(spades::AgentID agent, spades::AgentTypeDB::AgentTypeConstIterator at);
00199 
00204     bool agentDisappear(spades::AgentID agent, spades::AgentLostReason reason);
00205 
00211     void notifyCommserverConnect(spades::ServerID s);
00212 
00218     void notifyCommserverDisconnect(spades::ServerID s);
00219 
00220 protected:
00221     struct AgentItem
00222     {
00223         AgentItem(const std::string& agentType = "", int num = 0) :
00224             mAgentType(agentType), mNumber(num) {}
00225         std::string mAgentType;
00226         int mNumber;
00227     };
00228     typedef std::list<AgentItem> TAgentQueue;
00229 
00234     void StartAgents(const AgentItem& ai);
00235 
00236 private:
00238     spades::SimEngine* mSimEngine;
00239 
00241     boost::shared_ptr<ParamReader> mParamReader;
00242 
00244     bool mSimulationModeChanged;
00245 
00247     spades::SimulationMode mNewSimulationMode;
00248 
00250     TAgentQueue mAgentQueue;
00251 
00255     float mOffsetCreateSense;
00256 
00260     float mNextInitialCreateSense;
00261 
00263     boost::shared_ptr<MonitorServer> mMonitorServer;
00264 
00266     boost::shared_ptr<GameControlServer> mGameControlServer;
00267 
00269     boost::shared_ptr<SceneServer> mSceneServer;
00270 
00272     float mTimePerStep;
00273 };
00274 
00275 DECLARE_CLASS(SpadesServer);
00276 
00277 } // namespace oxygen
00278 
00279 #endif // OXYGEN_SPADESSERVER_H

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