00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
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
00053
00054
00055
00056 String getResultFileName(const String& botname);
00057 String getInfoFileName(const String& botname);
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);
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 }
00138
00139 # endif