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

robtopmgr.h

Go to the documentation of this file.
00001 /*
00002  * robtopmgr.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 
00020 #ifndef __RT_TOP_MANAGER__
00021 #define __RT_TOP_MANAGER__
00022 
00023 #include <rtstring.h>
00024 #include <rtfile.h>
00025 
00026 #include "robbase.h"
00027 #include "robmanage.h"
00028 
00029 using namespace lrt;
00030 
00031 namespace rt {
00032 
00033 class TopInfo;
00034 class TopTourResult;
00035 
00037 class TopManager : public SimManager{
00038 
00039 public:
00046         TopManager(bool importOld, int size, const String& competitionFolder);
00047         virtual ~TopManager();
00048 
00049         virtual void setup(SimOptions* const options);
00050         virtual void run();
00051 
00052         // Note that in all of the TopManager classes, "botname" means "bot file name"
00053         // unlike in the rest of RoboTour where it means "bot program name". 
00054         // All of these botnames must be file names localized against the competition folder
00055 
00056         String getResultFileName(const String& botname); // get the resultfile filename
00057         String getInfoFileName(const String& botname);   // get the infofile filename
00058         String getId(const String& botname);
00059         bool setIfInTop(const String& botname, const String& top);
00060 
00061         bool saveRes(const String& bot1, const String& bot2, int wins, int looses, int ties);
00062         TopInfo* updateBotInfo(const String& botname);
00063         bool doFights(const String& botname); // let a bot fight against the charts
00068         void readCharts(const IniFile& charts, Vector<TopTourResult>& store);
00071         void calcCharts(const IniFile& charts, Vector<TopTourResult>& store);
00073         void sortCharts(Vector<TopTourResult>& store);
00076         void checkChartsLength(IniFile& charts, Vector<TopTourResult>& store);
00077 
00079         bool updateCharts(IniFile& charts, const Array<TopTourResult>& store);
00080 
00084         bool addAndCheck(const String& botname);
00085 
00086 protected:
00087         TourInitInfo getTourInitInfo();
00088 
00089 private:
00090         bool importOld;
00091         int size;
00092         String chartsFileName;
00093         File competitionFolder;
00094         Vector<String> newFiles;
00095 };
00096 
00099 class TopInfo {
00100 public:
00101         TopInfo(const String& fileName);
00102         ~TopInfo();
00103 
00104         String fileName;
00105 
00106         StringMap<Program::HeaderField> headers; 
00107 
00108         String id;           
00109         Time date;         
00110         String top;          
00111 
00112         void fetchDate();        
00113         void incID();
00114         bool read();
00115         bool write();
00116 };
00117 
00119 class TopTourResult : public TourResult {
00120 public:
00121         static int compareByPoints(const TopTourResult& t1, const TopTourResult& t2);
00122         static int compareByDate(const TopTourResult& t1, const TopTourResult& t2);
00123         
00125         TopTourResult() : TourResult(), id(0), infoId(0), top(), date() {}
00127         TopTourResult(const StringMap<Program::HeaderField>& headers, const String& fileName) :
00128             TourResult(headers, fileName), id(0), infoId(0), top(), date()
00129         {}
00130 
00131         int id; 
00132         int infoId; 
00133         String top; 
00134         Time date;
00135 };
00136 
00137 } // namespace
00138 
00139 # endif

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