gStatList Class Reference

#include <gStatList.h>

Collaboration diagram for gStatList:

Collaboration graph
[legend]

List of all members.

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
tStatFilemyFile
tList< tStatEntryentries
int outputType


Detailed Description

Definition at line 36 of file gStatList.h.


Constructor & Destructor Documentation

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 }

Here is the call graph for this function:

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 }

Here is the call graph for this function:


Member Function Documentation

void gStatList::add ( tString  name,
REAL  value 
)

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 }

Here is the call graph for this function:

Here is the caller graph for this function:

void gStatList::update ( tString  name,
REAL  value 
)

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 }

Here is the call graph for this function:

Here is the caller graph for this function:

void gStatList::greater ( tString  name,
REAL  value 
)

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 }

Here is the call graph for this function:

Here is the caller graph for this function:

tString gStatList::getName (  ) 

Definition at line 91 of file gStatList.cpp.

References myName.

Referenced by getPlaceInList().

00092 {
00093     return myName;
00094 }

Here is the caller graph for this function:

REAL gStatList::getValue ( tString  name  ) 

Definition at line 97 of file gStatList.cpp.

References entries, and getPlaceInList().

Referenced by greater().

00098 {
00099     return entries[getPlaceInList(name)]->getValue();
00100 }

Here is the call graph for this function:

Here is the caller graph for this function:

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 }

Here is the call graph for this function:

Here is the caller graph for this function:

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 }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

tString gStatList::myName [private]

Definition at line 55 of file gStatList.h.

Referenced by getName(), and gStatList().

tStatFile* gStatList::myFile [private]

Definition at line 56 of file gStatList.h.

Referenced by gStatList(), output(), and ~gStatList().

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]

Definition at line 60 of file gStatList.h.

Referenced by gStatList(), output(), and ~gStatList().


The documentation for this class was generated from the following files:
Generated on Sat Mar 15 23:45:49 2008 for Armagetron Advanced by  doxygen 1.5.4