00001 /*************************************************************************** 00002 * Copyright (C) 2005-2011 LpzRobots development team * 00003 * Georg Martius <georg dot martius at web dot de> * 00004 * Frank Guettler <guettler at informatik dot uni-leipzig dot de * 00005 * Frank Hesse <frank at nld dot ds dot mpg dot de> * 00006 * Ralf Der <ralfder at mis dot mpg dot de> * 00007 * * 00008 * This program is free software; you can redistribute it and/or modify * 00009 * it under the terms of the GNU General Public License as published by * 00010 * the Free Software Foundation; either version 2 of the License, or * 00011 * (at your option) any later version. * 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 * 00020 * Free Software Foundation, Inc., * 00021 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00022 * * 00023 ***************************************************************************/ 00024 #ifndef __GLOBALDATA_H 00025 #define __GLOBALDATA_H 00026 00027 #include <vector> 00028 #include <map> 00029 #include "odehandle.h" 00030 #include "odeconfig.h" 00031 #include "sound.h" 00032 #include "tmpobject.h" 00033 #include <selforg/plotoption.h> 00034 #include <selforg/globaldatabase.h> 00035 #include <selforg/backcallervector.h> 00036 00037 class Configurable; 00038 00039 namespace lpzrobots { 00040 00041 class OdeAgent; 00042 class AbstractObstacle; 00043 class Primitive; 00044 class OSGPrimitive; 00045 00046 typedef std::vector<AbstractObstacle*> ObstacleList; 00047 typedef Configurable::configurableList ConfigList; 00048 typedef BackCallerVector<OdeAgent*> OdeAgentList; 00049 typedef std::list<Sound> SoundList; 00050 typedef std::list<PlotOption> PlotOptionList; 00051 typedef std::multimap<double, TmpObject* > TmpObjectMap; 00052 typedef std::list< std::pair<double, TmpObject*> > TmpObjectList; 00053 00054 /** 00055 Data structure holding all essential global information. 00056 */ 00057 class GlobalData : public GlobalDataBase { 00058 public: 00059 GlobalData() { 00060 sim_step = 0; 00061 environment = 0; 00062 } 00063 00064 virtual ~GlobalData() {} 00065 00066 OdeConfig odeConfig; 00067 ObstacleList obstacles; 00068 OdeAgentList agents; 00069 Primitive* environment; /// < this is used to be able to attach objects to the static environment 00070 00071 // Todo: the sound visualization could be done with the new TmpObjects 00072 SoundList sounds; ///< sound space 00073 00074 PlotOptionList plotoptions; ///< plotoptions used for new agents 00075 std::list<Configurable*> globalconfigurables; ///< global configurables plotted by all agents 00076 00077 double time; 00078 long int sim_step; ///< time steps since start 00079 00080 /// returns the list of all agents 00081 virtual AgentList& getAgents(); 00082 00083 00084 /// adds a temporary display item with given life duration in sec 00085 virtual void addTmpObject(TmpObject* i, double duration); 00086 00087 /// called by Simulation to initialize tmp objects 00088 virtual void initializeTmpObjects(const OdeHandle& odeHandle, 00089 const OsgHandle& osgHandle); 00090 /// called by Simulation to update tmp objects 00091 virtual void updateTmpObjects(const OsgHandle& osgHandle); 00092 00093 /** called by Simulation to removes all expired sounds and temporary objects. 00094 Optionally a time can be specified otherwise the internal time is used. 00095 */ 00096 virtual void removeExpiredObjects(double time = -1); 00097 00098 private: 00099 00100 TmpObjectList uninitializedTmpObjects; 00101 TmpObjectMap tmpObjects; 00102 AgentList baseAgents; 00103 }; 00104 00105 } 00106 00107 #endif