KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > polepos > reporters > Reporter


1 /*
2 This file is part of the PolePosition database benchmark
3 http://www.polepos.org
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public
16 License along with this program; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18 MA 02111-1307, USA. */

19
20 package org.polepos.reporters;
21
22 import java.io.*;
23
24 import org.polepos.framework.*;
25
26
27 /**
28  * base class for reporting the results.
29  */

30 public abstract class Reporter {
31     
32     protected final static String JavaDoc WEBSITE="http://www.polepos.org";
33     
34     protected final static String JavaDoc PATH="doc/results";
35         
36     protected Car mCar;
37     
38     protected Team mTeam;
39     
40     protected TeamCar mTeamCar;
41     
42     private boolean mTaskListPrinted;
43     
44     public Reporter(){
45         new File(PATH).mkdirs();
46     }
47     
48     public abstract String JavaDoc file();
49     
50     public abstract boolean append();
51     
52     public abstract void startSeason();
53     
54     public abstract void endSeason();
55     
56     public String JavaDoc path(){
57         return new File(PATH).getAbsolutePath();
58     }
59
60     public void sendToCircuit(Circuit circuit) {
61         mTaskListPrinted = false;
62     }
63     
64     public void noDriver(Team team, Circuit circuit) {
65         // default: do nothing
66
}
67     
68     public void report( Team team, Car car, TurnSetup[] setups, TurnResult[] results ){
69         
70         if(! mTaskListPrinted){
71             results[0].requestTaskNames(this);
72             mTaskListPrinted = true;
73         }
74         
75         if(team != mTeam){
76             mTeam = team;
77             reportTeam(team);
78         }
79         
80         if(car != mCar){
81             mCar = car;
82             reportCar(car);
83         }
84         
85         mTeamCar = new TeamCar(team, car);
86         
87         reportSetups(setups);
88         
89         for ( int i = 0; i < results.length; i++ ){
90             beginResults();
91             if(results[i] != null){
92                 results[i].report(this);
93             }
94         }
95     }
96         
97     public abstract void reportTaskName(int number, String JavaDoc name);
98     
99     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 }
112
Popular Tags