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 _SIMULATIONTASK_H_ 00025 #define _SIMULATIONTASK_H_ 00026 00027 #include "taskedsimulation.h" 00028 #include "taskedsimulationcreator.h" 00029 #include <string> 00030 #include <string.h> 00031 00032 namespace lpzrobots { 00033 00034 /** 00035 * 00036 */ 00037 class SimulationTask 00038 { 00039 public: 00040 SimulationTask(int taskId) : taskId(taskId), sim(0) { } 00041 00042 virtual ~SimulationTask() { } 00043 00044 virtual int startTask(SimulationTaskHandle& simTaskHandle, TaskedSimulationCreator& simTaskCreator, int* argc, char** argv, std::string nameSuffix) 00045 { 00046 int returnValue=0; 00047 sim = simTaskCreator.buildTaskedSimulationInstance(); 00048 if(sim!=0) 00049 { 00050 char buffer[20]; 00051 sprintf(buffer,"%i",taskId); 00052 sim->setTaskNameSuffix(std::string(" - ").append(nameSuffix).append(" - ").append(buffer)); 00053 sim->setTaskId(taskId); 00054 sim->setSimTaskHandle(simTaskHandle); 00055 returnValue = sim->run(*argc, argv)? 0 : 1; 00056 delete sim; 00057 return returnValue; 00058 } else 00059 return 1; 00060 } 00061 00062 protected: 00063 int taskId; 00064 TaskedSimulation* sim; 00065 }; 00066 00067 } 00068 00069 #endif /* _SIMULATIONTASK_H_ */