Robot Simulator of the Robotics Group for Self-Organization of Control  0.8.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
simulationtask.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2011 LpzRobots development team *
3  * Georg Martius <georg dot martius at web dot de> *
4  * Frank Guettler <guettler at informatik dot uni-leipzig dot de *
5  * Frank Hesse <frank at nld dot ds dot mpg dot de> *
6  * Ralf Der <ralfder at mis dot mpg dot de> *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the *
20  * Free Software Foundation, Inc., *
21  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
22  * *
23  ***************************************************************************/
24 #ifndef _SIMULATIONTASK_H_
25 #define _SIMULATIONTASK_H_
26 
27 #include "taskedsimulation.h"
29 #include <string>
30 #include <string.h>
31 
32 namespace lpzrobots {
33 
34  /**
35  *
36  */
38  {
39  public:
40  SimulationTask(int taskId) : taskId(taskId), sim(0) { }
41 
42  virtual ~SimulationTask() { }
43 
44  virtual int startTask(SimulationTaskHandle& simTaskHandle, TaskedSimulationCreator& simTaskCreator, int* argc, char** argv, std::string nameSuffix)
45  {
46  int returnValue=0;
47  sim = simTaskCreator.buildTaskedSimulationInstance();
48  if(sim!=0)
49  {
50  char buffer[20];
51  sprintf(buffer,"%i",taskId);
52  sim->setTaskNameSuffix(std::string(" - ").append(nameSuffix).append(" - ").append(buffer));
54  sim->setSimTaskHandle(simTaskHandle);
55  returnValue = sim->run(*argc, argv)? 0 : 1;
56  delete sim;
57  return returnValue;
58  } else
59  return 1;
60  }
61 
62  protected:
63  int taskId;
65  };
66 
67 }
68 
69 #endif /* _SIMULATIONTASK_H_ */
void setSimTaskHandle(SimulationTaskHandle &simTaskHandle)
Sets the global SimulationTaskHandle.
Definition: taskedsimulation.h:108
TaskedSimulation * sim
Definition: simulationtask.h:64
void setTaskId(int taskId)
Sets the taskId of the associated SimulationTask.
Definition: taskedsimulation.h:89
Definition: taskedsimulation.h:34
virtual ~SimulationTask()
Definition: simulationtask.h:42
Definition: simulationtask.h:37
bool run(int argc, char **argv)
starts the Simulation.
Definition: simulation.cpp:419
SimulationTask(int taskId)
Definition: simulationtask.h:40
struct which holds all structural data for the simulations.
Definition: simulationtaskhandle.h:37
virtual int startTask(SimulationTaskHandle &simTaskHandle, TaskedSimulationCreator &simTaskCreator, int *argc, char **argv, std::string nameSuffix)
Definition: simulationtask.h:44
void setTaskNameSuffix(std::string nameSuffix)
Definition: taskedsimulation.h:99
Defines a method to construct a TaskedSimulation.
Definition: taskedsimulationcreator.h:36
int taskId
Definition: simulationtask.h:63
virtual TaskedSimulation * buildTaskedSimulationInstance()=0
Builds (constructs) an instance of TaskedSimulation.