Back to index

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

Simple class to load and manage track data, track names and such. More...

#include <track_manager.hpp>

Collaboration diagram for TrackManager:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 TrackManager ()
 ~TrackManager ()
TrackgetTrack (const std::string &ident) const
 get TrackData by the track ident (aka filename without .track)
TrackgetTrack (size_t id) const
size_t getTrackCount () const
void loadTrackList ()
 initialize the track list by searching through all directories for .track files

Private Types

typedef std::vector< Track * > Tracks

Private Attributes

Tracks m_tracks

Detailed Description

Simple class to load and manage track data, track names and such.

Definition at line 29 of file track_manager.hpp.


Member Typedef Documentation

typedef std::vector<Track*> TrackManager::Tracks [private]

Definition at line 32 of file track_manager.hpp.


Constructor & Destructor Documentation

Definition at line 31 of file track_manager.cpp.

{}   // TrackManager

Definition at line 35 of file track_manager.cpp.

{
    for(Tracks::iterator i = m_tracks.begin(); i != m_tracks.end(); ++i)
        delete *i;
}   // ~TrackManager

Member Function Documentation

Track * TrackManager::getTrack ( const std::string &  ident) const

get TrackData by the track ident (aka filename without .track)

Definition at line 42 of file track_manager.cpp.

{
    for(Tracks::const_iterator i = m_tracks.begin(); i != m_tracks.end(); ++i)
    {
        if ((*i)->getIdent() == ident)
            return *i;
    }

    char msg[MAX_ERROR_MESSAGE_LENGTH];
    fprintf(stderr, "TrackManager: Couldn't find track: '%s'", ident.c_str() );
    throw std::runtime_error(msg);
}   // getTrack

Here is the caller graph for this function:

Track * TrackManager::getTrack ( size_t  id) const

Definition at line 56 of file track_manager.cpp.

{
    return m_tracks[id];
}  // getTrack
size_t TrackManager::getTrackCount ( ) const

Definition at line 62 of file track_manager.cpp.

{
    return m_tracks.size();
}   // getTrackCount

Here is the caller graph for this function:

initialize the track list by searching through all directories for .track files

Definition at line 68 of file track_manager.cpp.

{
    // Load up a list of tracks - and their names
    std::set<std::string> dirs;
    file_manager->listFiles(dirs, file_manager->getTrackDir(), /*is_full_path*/ true);
    for(std::set<std::string>::iterator dir = dirs.begin(); dir != dirs.end(); dir++)
    {
        if(*dir=="." || *dir=="..") continue;
        std::string config_file;
        try
        {
            // getTrackFile appends dir, so it's opening: *dir/*dir.track
            config_file = file_manager->getTrackFile((*dir)+".track");
        }
        catch (std::exception& e)
        {
            (void)e;   // remove warning about unused variable
            continue;
        }
        FILE *f=fopen(config_file.c_str(),"r");
        if(!f) continue;

        m_tracks.push_back(new Track(config_file));

        // Read music files in that dir as well
        sound_manager->loadMusicFromOneDir(*dir);
    }
}  // loadTrackList

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 33 of file track_manager.hpp.


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