Back to index

supertuxkart  0.5+dfsg1
Public Member Functions | Private Attributes
CupData Class Reference

Simple class that hold the data relevant to a 'cup', aka. More...

#include <cup_data.hpp>

Collaboration diagram for CupData:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 CupData (const std::string filename)
 Load the CupData from the given filename.
 CupData ()
const std::string & getName () const
const std::string & getDescription () const
const std::string & getHerringStyle () const
const std::string & getFilename () const
const std::string & getTrack (size_t track_index) const
const std::vector< std::string > & getTracks () const
const std::vector< int > & getLaps () const
size_t getTrackCount () const
const int & getLaps (size_t lap_index) const

Private Attributes

std::string m_name
std::string m_filename
std::string m_description
std::string m_herring_style
std::vector< std::string > m_tracks
 The ident of the tracks in this cup in their right order, ident means the filename of the .track file without .track extension (ie.
std::vector< int > m_laps
 The number of laps that each track should be raced, in the right order.

Detailed Description

Simple class that hold the data relevant to a 'cup', aka.

a number of races that has to be completed one after the other

Definition at line 32 of file cup_data.hpp.


Constructor & Destructor Documentation

CupData::CupData ( const std::string  filename)

Load the CupData from the given filename.

Definition at line 28 of file cup_data.cpp.

{
    m_filename = filename_;
    const lisp::Lisp* lisp = 0;
    try
    {
        lisp::Parser parser;
        lisp = parser.parse(file_manager->getConfigFile(m_filename));

        lisp = lisp->getLisp("supertuxkart-cup");
        if(!lisp)
        {
            throw std::runtime_error("No supertuxkart-cup node");
        }

        lisp->get      ("name",        m_name        );
        lisp->get      ("description", m_description );
        lisp->get      ("herring",     m_herring_style);
        lisp->getVector("tracks",      m_tracks      );
        lisp->getVector("laps",        m_laps        );
    }
    catch(std::exception& err)
    {
        fprintf(stderr, "Error while reading cup file '%s'\n", filename_.c_str());
        fprintf(stderr, err.what());
        fprintf(stderr, "\n");
    }

    delete lisp;
}

Here is the call graph for this function:

CupData::CupData ( ) [inline]

Definition at line 50 of file cup_data.hpp.

{}; // empty for initialising

Member Function Documentation

const std::string& CupData::getDescription ( ) const [inline]

Definition at line 52 of file cup_data.hpp.

{ return m_description;   }

Here is the caller graph for this function:

const std::string& CupData::getFilename ( ) const [inline]

Definition at line 54 of file cup_data.hpp.

{ return m_filename;      }

Here is the caller graph for this function:

const std::string& CupData::getHerringStyle ( ) const [inline]

Definition at line 53 of file cup_data.hpp.

{ return m_herring_style; }

Here is the caller graph for this function:

const std::vector<int>& CupData::getLaps ( ) const [inline]

Definition at line 58 of file cup_data.hpp.

{return m_laps;          }

Here is the caller graph for this function:

const int& CupData::getLaps ( size_t  lap_index) const [inline]

Definition at line 60 of file cup_data.hpp.

                                                       {assert(lap_index < m_tracks.size()); 
                                                         return m_laps[lap_index]; }
const std::string& CupData::getName ( ) const [inline]

Definition at line 51 of file cup_data.hpp.

{ return m_name;          }

Here is the caller graph for this function:

const std::string& CupData::getTrack ( size_t  track_index) const [inline]

Definition at line 55 of file cup_data.hpp.

                                                        { assert(track_index < m_tracks.size()); 
                                                       return m_tracks[track_index]; }
size_t CupData::getTrackCount ( ) const [inline]

Definition at line 59 of file cup_data.hpp.

{return m_tracks.size(); }
const std::vector<std::string>& CupData::getTracks ( ) const [inline]

Definition at line 57 of file cup_data.hpp.

{return m_tracks;        }

Here is the caller graph for this function:


Member Data Documentation

std::string CupData::m_description [private]

Definition at line 36 of file cup_data.hpp.

std::string CupData::m_filename [private]

Definition at line 35 of file cup_data.hpp.

std::string CupData::m_herring_style [private]

Definition at line 37 of file cup_data.hpp.

std::vector<int> CupData::m_laps [private]

The number of laps that each track should be raced, in the right order.

Definition at line 44 of file cup_data.hpp.

std::string CupData::m_name [private]

Definition at line 34 of file cup_data.hpp.

std::vector<std::string> CupData::m_tracks [private]

The ident of the tracks in this cup in their right order, ident means the filename of the .track file without .track extension (ie.

'volcano')

Definition at line 41 of file cup_data.hpp.


The documentation for this class was generated from the following files: