001: /*
002: This file is part of the PolePosition database benchmark
003: http://www.polepos.org
004:
005: This program is free software; you can redistribute it and/or
006: modify it under the terms of the GNU General Public License
007: as published by the Free Software Foundation; either version 2
008: of the License, or (at your option) any later version.
009:
010: This program is distributed in the hope that it will be useful,
011: but WITHOUT ANY WARRANTY; without even the implied warranty of
012: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
013: GNU General Public License for more details.
014:
015: You should have received a copy of the GNU General Public
016: License along with this program; if not, write to the Free
017: Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
018: MA 02111-1307, USA. */
019:
020: package org.polepos.reporters;
021:
022: import java.io.*;
023:
024: import org.polepos.framework.*;
025:
026: /**
027: * base class for reporting the results.
028: */
029: public abstract class Reporter {
030:
031: protected final static String WEBSITE = "http://www.polepos.org";
032:
033: protected final static String PATH = "doc/results";
034:
035: protected Car mCar;
036:
037: protected Team mTeam;
038:
039: protected TeamCar mTeamCar;
040:
041: private boolean mTaskListPrinted;
042:
043: public Reporter() {
044: new File(PATH).mkdirs();
045: }
046:
047: public abstract String file();
048:
049: public abstract boolean append();
050:
051: public abstract void startSeason();
052:
053: public abstract void endSeason();
054:
055: public String path() {
056: return new File(PATH).getAbsolutePath();
057: }
058:
059: public void sendToCircuit(Circuit circuit) {
060: mTaskListPrinted = false;
061: }
062:
063: public void noDriver(Team team, Circuit circuit) {
064: // default: do nothing
065: }
066:
067: public void report(Team team, Car car, TurnSetup[] setups,
068: TurnResult[] results) {
069:
070: if (!mTaskListPrinted) {
071: results[0].requestTaskNames(this );
072: mTaskListPrinted = true;
073: }
074:
075: if (team != mTeam) {
076: mTeam = team;
077: reportTeam(team);
078: }
079:
080: if (car != mCar) {
081: mCar = car;
082: reportCar(car);
083: }
084:
085: mTeamCar = new TeamCar(team, car);
086:
087: reportSetups(setups);
088:
089: for (int i = 0; i < results.length; i++) {
090: beginResults();
091: if (results[i] != null) {
092: results[i].report(this );
093: }
094: }
095: }
096:
097: public abstract void reportTaskName(int number, String name);
098:
099: protected abstract void reportTeam(Team team);
100:
101: protected abstract void reportCar(Car car);
102:
103: public void reportSetups(TurnSetup[] setups) {
104:
105: }
106:
107: protected abstract void beginResults();
108:
109: public abstract void reportResult(Result result);
110:
111: }
|