//
//  SuperTuxKart - a fun racing game with go-kart
//  Copyright (C) 2006-2015 SuperTuxKart-Team
//
//  This program is free software; you can redistribute it and/or
//  modify it under the terms of the GNU General Public License
//  as published by the Free Software Foundation; either version 3
//  of the License, or (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program; if not, write to the Free Software
//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

#ifndef HEADER_TRACK_MANAGER_HPP
#define HEADER_TRACK_MANAGER_HPP

#include <string>
#include <vector>
#include <map>

class Map;

/**
  * \brief Simple class to load and manage track data, track names and such
  * \ingroup tracks
  */
class MapManager
{
private:
    /** All directories in which tracks are searched. */
    static std::vector<std::string>          m_map_search_path;

    /** All directories in which tracks were found. */
    std::vector<std::string>                 m_all_map_dirs;

    typedef std::vector<Map*>              Maps;

    /** All track objects. */
    Maps                                  m_maps;




public:
                MapManager();
               ~MapManager();

    static void addMapSearchDir(const std::string &dir);
    /** Returns a list of all track identifiers. */
    std::vector<std::string> getAllMapIdentifiers();

    /** Load all .track files from all directories */
    void  loadMapList();
    void  removeMap(const std::string &ident);
    bool  loadMap(const std::string& dirname);
    void  removeAllCachedData();

    Map* getMap(const std::string& ident) const;

    // ------------------------------------------------------------------------
    /** \brief Returns a list of all directories that contain a track. */
    const std::vector<std::string>* getAllMapDirs() const
    {
        return &m_all_map_dirs;
    }   // getAllTrackDirs


    // ------------------------------------------------------------------------
    /** Returns the number of tracks. */
    size_t getNumberOfMaps() const { return m_maps.size(); }
    // ------------------------------------------------------------------------
    /** Returns the track with a given index number.
     *  \param index The index number of the track. */
    Map* getMap(unsigned int index) const { return m_maps[index];}
    // ------------------------------------------------------------------------
    /** Checks if a certain track is available.
     *  \param n Index of the track to check. */




};   // TrackManager

extern MapManager* map_manager;

#endif   // HEADER_TRACK_MANAGER_HPP
