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

simulationserver.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: simulationserver.h,v 1.3 2004/12/22 15:58:26 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 OXYGEN_SIMULATIONSERVER_H
00023 #define OXYGEN_SIMULATIONSERVER_H
00024 
00025 #include <zeitgeist/node.h>
00026 
00027 namespace oxygen
00028 {
00029 class GameControlServer;
00030 class MonitorServer;
00031 class SceneServer;
00032 class SimControlNode;
00033 
00034 class SimulationServer : public zeitgeist::Node
00035 {
00042 public:
00043     enum EControlEvent
00044         {
00045             CE_Init, // the simulation is initially started
00046             CE_Done, // the simulation is shut down
00047             CE_StartCycle, // a new cycle of the simulation loop
00048                            // started
00049             CE_SenseAgent, // collect sensor data and send it to the
00050                            // agents
00051             CE_ActAgent,   // collect (and possibly wait for) agent
00052                            // commands and carry them out
00053             CE_EndCycle // the current cycle ended
00054         };
00055 
00056 public:
00057     SimulationServer();
00058     ~SimulationServer();
00059 
00061     static void Quit();
00062 
00064     virtual float GetTime();
00065 
00067     virtual void SetSimStep(float deltaTime);
00068 
00070     virtual float GetSimStep();
00071 
00075     virtual void AdvanceTime(float deltaTime);
00076 
00079     virtual float GetSumDeltaTime();
00080 
00083     bool InitControlNode(const std::string& className, const std::string& name);
00084 
00091     void SetAutoTimeMode(bool set);
00092 
00094     bool GetAutoTimeMode();
00095 
00097     boost::shared_ptr<oxygen::SimControlNode>
00098     GetControlNode(const std::string& controlName);
00099 
00101     int GetArgC();
00102 
00104     char** GetArgV();
00105 
00107     virtual void Run(int argc = 0, char** argv = 0);
00108 
00110     boost::shared_ptr<MonitorServer> GetMonitorServer();
00111 
00113     boost::shared_ptr<GameControlServer> GetGameControlServer();
00114 
00116     boost::shared_ptr<SceneServer> GetSceneServer();
00117 
00119     int GetCycle();
00120 
00121 protected:
00122     virtual void OnLink();
00123     virtual void OnUnlink();
00124 
00127     virtual void Step();
00128 
00129 protected:
00134     void ControlEvent(EControlEvent event);
00135 
00137     static void CatchSignal(int sig_num);
00138 
00139 protected:
00141     int mArgC;
00142 
00144     char** mArgV;
00145 
00147     static bool mExit;
00148 
00150     float mSimTime;
00151 
00154     float mSimStep;
00155 
00158     float mSumDeltaTime;
00159 
00163     bool mAutoTime;
00164 
00166     int mCycle;
00167 
00169     boost::shared_ptr<MonitorServer> mMonitorServer;
00170 
00172     boost::shared_ptr<GameControlServer> mGameControlServer;
00173 
00175     boost::shared_ptr<SceneServer> mSceneServer;
00176 };
00177 
00178 DECLARE_CLASS(SimulationServer);
00179 
00180 } // namespace oxygen
00181 
00182 #endif // OXYGEN_SIMULATIONSERVER_H

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