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

robstreamif.h

Go to the documentation of this file.
00001 /*
00002  * robstreamif.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 
00022 #ifndef __RT_STREAMIF__
00023 #define __RT_STREAMIF__
00024 
00025 #include "robfrontend.h"
00026 #include "robbase.h"
00027 #include "robmanage.h"
00028 
00029 #include <rtstring.h>
00030 #include <rtcollect.h>
00031 
00032 namespace rt{
00033 
00034 enum StreamifMode {
00035         sifModeOld,
00036         sifModeRT3
00037 };
00038 
00039 enum StreamifDispType {
00040         sifDispNone = 0,
00041         sifDispRunningBankOwner,
00042         sifDispGeneration,
00043         sifDispNumBanks,
00044         sifDispRunningBank
00045 };
00046 
00047 // simple array for command listings
00048 struct SifSimpleStringArray {
00049         int length;
00050         char* strs[20];
00051 };
00052 
00053 // fwd declare
00054 class StreamSimSupervisor;
00055 class StreamTourDisplayer;
00056 
00057 class StreamInterface : public FrontendPlugin  
00058 {
00059 public:
00060         StreamInterface(Frontend* parent);
00061         virtual ~StreamInterface();
00062 
00063         virtual FpInterpretePos getInterpretePos();
00064         virtual String getName();
00065         virtual String getHelpText();
00066         virtual bool interpreteParams(const Array<String>& params, Array<bool>& used);
00067         virtual void fillOptions(SimOptions& options);
00068 
00069         // reads a command or parameter
00070         String read();
00071         // writes a result or status message
00072         void write(const String&);
00073         // writes a simple array
00074         void writeArray(SifSimpleStringArray*);
00075 
00076 private:
00077         Array<String>* curLine;
00078         int curPos;
00079         StreamifMode mode;
00080         Frontend::FightType fightType;
00081         Vector<int> curBotNums;
00082 
00083         static SifSimpleStringArray setupCommands;
00084         static SifSimpleStringArray ttypeOptions;
00085         static SifSimpleStringArray modeOptions;
00086 
00087         friend class StreamSimSupervisor;
00088         friend class StreamTourDisplayer;
00089 };
00090 
00091 class StreamSimSupervisor : public SimSupervisor {
00092 
00093 public:
00094         StreamSimSupervisor(StreamInterface* parent);
00095         virtual ~StreamSimSupervisor();
00096 
00097         virtual SimSuperPosition getPreferredPosition();
00098         virtual unsigned long getStepCycles();
00099         virtual void initSim(Simulation* const sim);
00100         virtual GameState exec(Simulation* const sim);
00101         virtual void exitSim(Simulation* const sim, const GameState& simResult);
00102 
00103 private:
00104         StreamInterface* parent;
00105         StreamifDispType dispType;
00106         unsigned long step;
00107         SimSupervisor::GameState retState;
00108 
00109         static SifSimpleStringArray runCommands;
00110         static SifSimpleStringArray displayOptions;
00111 };
00112 
00113 class StreamTourDisplayer : public TourDisplayer {
00114 
00115 public:
00116         StreamTourDisplayer(StreamInterface* parent);
00117         virtual ~StreamTourDisplayer();
00118 
00119         virtual void init(const TourInitInfo&);
00120         virtual TourStatusType update(const Array<TourResult>& status);
00121         virtual void exit(TourStatusType exitType, const Array<TourResult>& result);
00122 
00123 private:
00124         StreamInterface* parent;
00125 };
00126 
00127 class StreamErrorHandler : public ErrorHandler {
00128 public:
00129         StreamErrorHandler(StreamInterface* parent);
00130         virtual ~StreamErrorHandler();
00131 
00132         virtual void handleBotError(const Bot* affectedBot, ExecReturnType type) const;
00133         virtual void handleLoadError(const String& affectedFile, const String& message) const;
00134         virtual void handleSystemError(int num, const String& message) const;
00135 
00136 private:
00137         StreamInterface* parent;
00138 };
00139 
00140 
00141 
00142 } // namespace
00143 
00144 #endif 

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