Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

robvis.h

00001 /*
00002  * robvis.h
00003  * 
00004  * Copyright (c) 2000-2004 by Florian Fischer (florianfischer@gmx.de)
00005  * and Martin Trautmann (martintrautmann@gmx.de) 
00006  * 
00007  * This file may be distributed and/or modified under the terms of the 
00008  * GNU General Public License version 2 as published by the Free Software 
00009  * Foundation. 
00010  * 
00011  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013  * 
00014  */
00015 
00016 // visualization related non-GUI classes (sim-supervisors, tournament handlers)
00017 
00018 #ifndef __RT_LRTVIS__
00019 #define __RT_LRTVIS__
00020 
00021 #include "robwxfe.h"
00022 #include "robmanage.h"
00023 #include "robbase.h"
00024 #include "robwxstruct.h"
00025 
00026 #include <rtsystem.h>
00027 #include <rtstreams.h>
00028 
00029 using namespace lrt;
00030 
00031 class wxEvent;
00032 class wxStopWatch;
00033 
00034 namespace rt {
00035 
00036 
00037 // helper functions
00038 // mini helpie function: checks if we have a frame to do something for
00039 bool HaveVisFrame();
00040 // helpey function: waits until the event was really processed
00041 // maxWait: max time to wait (msec)
00042 // ALWAYS use this one!
00043 void PostAndWait(wxEvent& evt, int maxWait = 1000);
00044 // special value for maxWait
00045 enum {
00046         WaitInfinite = -1
00047 };
00048 
00049 // predeclasses
00050 class VisPlugin;
00051 class VisSupervisor;
00052 class VisTourDisplayer;
00053 class VisDebugSupervisor;
00054 
00055 // classes
00056 class VisPlugin : public FrontendPlugin  
00057 {
00058 public:
00059         virtual FpInterpretePos getInterpretePos();
00060         virtual String getName();
00061         virtual String getHelpText();
00062         virtual bool interpreteParams(const Array<String>& params, Array<bool>& used);
00063         virtual void fillOptions(SimOptions& options);
00064         VisPlugin(Frontend* parent);
00065         ~VisPlugin();
00066 private:
00067 };
00068 
00069 class VisSupervisor : public SimSupervisor
00070 {
00071 public:
00072         VisSupervisor(VisDebugSupervisor* debugger = 0);
00073         ~VisSupervisor();
00074         virtual unsigned long getStepCycles();
00075         virtual void initSim(Simulation* const sim);
00076         virtual GameState exec(Simulation* const curSim);
00077         virtual void exitSim(Simulation* const curSim, const GameState& simResult);
00078         void updateTour(const Array<TourResult>& tourStatus);
00079 
00080 private: 
00081         friend class VisTourDisplayer;
00082 
00083         void processGuiRequests(Simulation* sim);
00084 
00085         Vector<TourResult> tourStatus; 
00086         TourInitInfo initInfo;
00087         int curSimNum; 
00088 
00089         wxStopWatch* watch;
00090 
00091         VisDebugSupervisor* debugger;
00092 };
00093 
00094 class VisTourDisplayer : public TourDisplayer {
00095 
00096 public:
00097         VisTourDisplayer(VisSupervisor* super);
00098 
00099         virtual TourStatusType update(const Array<TourResult>& status);
00100         virtual void init(const TourInitInfo& info) { super->initInfo = info; super->curSimNum = 0; }
00101         virtual void exit(TourStatusType exitType, const Array<TourResult>& result) {}
00102 private:
00103         VisSupervisor* super;
00104 };
00105 
00106 
00107 class VisDebugSupervisor : public SimSupervisor, public BotErrorHandler 
00108 {
00109 public:
00110         VisDebugSupervisor(Frontend* parent);
00111         ~VisDebugSupervisor();
00112         virtual unsigned long getStepCycles();
00113         virtual void initSim(Simulation* const sim);
00114         virtual GameState exec(Simulation* const curSim);
00115         virtual void exitSim(Simulation* const curSim, const GameState& simResult);
00116         virtual void handleBotError(const Bot* affectedBot, ExecReturnType type);
00117 
00118 private: 
00119         void processGuiRequests(Simulation* sim); // my own (debug) requests
00120         friend class VisSupervisor;
00121 
00122         Map<int, DebugInfo> debugInfo;
00123         int nextDebugID;
00124         WxFrontend* parent; // can be 0 (if another frontend is being used)
00125 };
00126 
00127 } // namespace
00128 
00129 #endif
00130 

This is the RoboTour API documentation version 0.1 • Copyright (C) by Florian Fischer