Robot Simulator of the Robotics Group for Self-Organization of Control: simulationtask.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages
- Examples

- Search for |

- File List
- File Members

# simulationtask.h

Go to the documentation of this file.

    00001 /***************************************************************************
    00002  *   Copyright (C) 2005 by Robot Group Leipzig                             *
    00003  *    martius@informatik.uni-leipzig.de                                    *
    00004  *    fhesse@informatik.uni-leipzig.de                                     *
    00005  *    der@informatik.uni-leipzig.de                                        *
    00006  *    guettler@informatik.uni-leipzig.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  *  DESCRIPTION                                                            *
    00025  *                                                                         *
    00026  *                                                                         *
    00027  *                                                                         *
    00028  *                                                                         *
    00029  *                                                                         *
    00030  * $Log: simulationtask.h,v $
    00031  * Revision 1.2  2009/08/21 09:49:07  robot12
    00032  * (guettler) support for tasked simulations.
    00033  * - use the simulation template_taskedSimulations.
    00034  * - merged (not completely) from lpzrobots_tasked.
    00035  * - graphics is supported, but only for one simulation of a pool
    00036  *
    00037  * Revision 1.1.2.1  2009/08/11 15:59:20  guettler
    00038  * - support for tasked simulations, does not yet work with graphics
    00039  * - in development state
    00040  * *
    00041  *                                                                         *
    00042  ***************************************************************************/
    00043 #ifndef _SIMULATIONTASK_H_
    00044 #define _SIMULATIONTASK_H_
    00045
    00046 #include "taskedsimulation.h"
    00047 #include "taskedsimulationcreator.h"
    00048 #include <string>
    00049 #include <string.h>
    00050
    00051 namespace lpzrobots {
    00052
    00053   /**
    00054    *
    00055    */
    00056   class SimulationTask
    00057   {
    00058   public:
    00059     SimulationTask(int taskId) : taskId(taskId), sim(0) { }
    00060
    00061     virtual ~SimulationTask() { }
    00062
    00063     virtual int startTask(SimulationTaskHandle& simTaskHandle, TaskedSimulationCreator& simTaskCreator, int* argc, char** argv, std::string nameSuffix)
    00064     {
    00065       int returnValue=0;
    00066       sim = simTaskCreator.buildTaskedSimulationInstance();
    00067       if(sim!=0)
    00068       {
    00069         char buffer[20];
    00070         sprintf(buffer,"%i",taskId);
    00071         sim->setTaskNameSuffix(std::string(" - ").append(nameSuffix).append(" - ").append(buffer));
    00072         sim->setTaskId(taskId);
    00073         sim->setSimTaskHandle(simTaskHandle);
    00074         returnValue = sim->run(*argc, argv)? 0 : 1;
    00075         delete sim;
    00076         return returnValue;
    00077       } else
    00078         return 1;
    00079     }
    00080
    00081   protected:
    00082     int taskId;
    00083     TaskedSimulation* sim;
    00084   };
    00085
    00086 }
    00087
    00088 #endif /* _SIMULATIONTASK_H_ */