#include <gStatList.h>
Public Member Functions | |
gStatList (const char *name, int oType) | |
void | add (tString name, REAL value) |
void | update (tString name, REAL value) |
void | greater (tString name, REAL value) |
tString | getName () |
REAL | getValue (tString name) |
~gStatList () | |
Private Member Functions | |
int | getPlaceInList (tString name) |
void | output (int c) |
Private Attributes | |
tString | myName |
tStatFile * | myFile |
tList< tStatEntry > | entries |
int | outputType |
Definition at line 36 of file gStatList.h.
gStatList::gStatList | ( | const char * | name, | |
int | oType | |||
) |
Definition at line 33 of file gStatList.cpp.
References entries, myFile, myName, outputType, and tStatFile::read().
00034 { 00035 myName = name; 00036 outputType = oType; 00037 00038 if (outputType == 0) 00039 { 00040 myFile = new tStatFile(myName, &entries); 00041 myFile->read(); 00042 } 00043 00044 // std::cout << "i am " << name << " and i have " << entries.Len() << " values\n"; 00045 // int c = getPlaceInList(tString("tank program")); 00046 // std::cout << "i am " << name << " and i have " << entries.Len() << " values\n"; 00047 // add(tString("Tank Program"), 8); 00048 // add(tString("guru3"), 2); 00049 // add(tString("insaneo"), 5); 00050 // add(tString("randman"), 1); 00051 // add(tString("aguy"), 7); 00052 // std::cout << "we have " << entries[c]->getName() << " with " << entries[c]->getValue() << "!\n"; 00053 00054 // std::cout << entries.Len() << " entries\n"; 00055 00056 // for (int c = 0; c < entries.Len(); c++) 00057 // { 00058 // std::cout << getName() << ": " << entries[c]->getName() << " has score " << entries[c]->getValue() << " (" << c << ")\n"; 00059 // } 00060 00061 // std::cout << "constructed!\n"; 00062 }
gStatList::~gStatList | ( | ) |
Definition at line 132 of file gStatList.cpp.
References c, entries, GrowingArrayBase::Len(), myFile, outputType, and tList< T, MALLOC, REFERENCE >::Remove().
00133 { 00134 if (outputType == 0) 00135 { 00136 delete myFile; 00137 } 00138 00139 for (int c = 0; c < entries.Len(); c++) 00140 { 00141 entries.Remove(entries[c], entries[c]->id); 00142 } 00143 }
Definition at line 65 of file gStatList.cpp.
References c, entries, getPlaceInList(), and output().
Referenced by gGame::Analysis(), and gCycle::KillAt().
00066 { 00067 int c = getPlaceInList(name); 00068 entries[c]->addValue(value); 00069 output(c); 00070 }
Definition at line 73 of file gStatList.cpp.
References c, entries, getPlaceInList(), and output().
Referenced by greater().
00074 { 00075 int c = getPlaceInList(name); 00076 entries[c]->setValue(value); 00077 output(c); 00078 }
Definition at line 81 of file gStatList.cpp.
References c, entries, getPlaceInList(), getValue(), and update().
Referenced by gGame::Analysis().
00082 { 00083 int c = getPlaceInList(name); 00084 if (entries[c]->getValue() < value) 00085 { 00086 update(name, value); 00087 } 00088 }
tString gStatList::getName | ( | ) |
Definition at line 91 of file gStatList.cpp.
References myName.
Referenced by getPlaceInList().
00092 { 00093 return myName; 00094 }
Definition at line 97 of file gStatList.cpp.
References entries, and getPlaceInList().
Referenced by greater().
00098 { 00099 return entries[getPlaceInList(name)]->getValue(); 00100 }
int gStatList::getPlaceInList | ( | tString | name | ) | [private] |
Definition at line 102 of file gStatList.cpp.
References tList< T, MALLOC, REFERENCE >::Add(), c, entries, getName(), tStatEntry::id, and GrowingArrayBase::Len().
Referenced by add(), getValue(), greater(), and update().
00103 { 00104 // std::cout << myName << ": getting place\n"; 00105 00106 for (int c = 0; c < entries.Len(); c++) 00107 { 00108 if (entries[c]->getName() == name) 00109 { 00110 return c; 00111 } 00112 } 00113 00114 // std::cout << myName << ": adding place\n"; 00115 00116 //didn't find it, add it 00117 tStatEntry *newone = new tStatEntry(name); 00118 entries.Add(newone, newone->id); 00119 return getPlaceInList(name); 00120 }
void gStatList::output | ( | int | c | ) | [private] |
Definition at line 122 of file gStatList.cpp.
References entries, myFile, outputType, and tStatFile::write().
Referenced by add(), and update().
00123 { 00124 entries[c]->toWrite = true; 00125 00126 if (outputType == 0) 00127 { 00128 myFile->write(); 00129 } 00130 }
tString gStatList::myName [private] |
tStatFile* gStatList::myFile [private] |
tList<tStatEntry> gStatList::entries [private] |
Definition at line 57 of file gStatList.h.
Referenced by add(), getPlaceInList(), getValue(), greater(), gStatList(), output(), update(), and ~gStatList().
int gStatList::outputType [private] |