1 // Copyright (C) 2007, 2008, 2009 Ben Asselstine
3 // This program is free software; you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation; either version 3 of the License, or
6 // (at your option) any later version.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU Library General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 #include "LocationList.h"
22 #include <sigc++/trackable.h>
26 //! A list of Road objects on the game map.
28 * The roadlist keeps track of the roads located on the game map. It
29 * is implemented as a singleton because many classes use it for looking up
32 class Roadlist : public LocationList<Road*>, public sigc::trackable
35 //! The xml tag of this object in a saved-game file.
36 static std::string d_tag;
38 // Methods that operate on the class data but do not modify the class.
40 //! Saves the list of roads to the opened saved-game file.
41 bool save(XML_Helper* helper) const;
43 //! Determines what the right Road::Type should be for the given tile.
45 * Scans the surrounding tiles to see which road picture fits best.
47 * @param tile The position on the game map to calculate a road type
50 * @return The Road::Type that makes the most sense for the given tile.
52 int calculateType (Vector<int> tile) const;
56 //! Return the singleton instance. Create a new one if needed.
57 static Roadlist* getInstance();
59 //! Load the singleton instance from the opened saved-game file.
60 static Roadlist* getInstance(XML_Helper* helper);
62 //! Explicitly delete the singleton instance.
63 static void deleteInstance();
66 //! Default constructor.
69 //! Loading constructor.
71 * Make a new roadlist object by loading it from the opened saved-game
74 * @param helper The opened saved game file to load the list of roads
77 Roadlist(XML_Helper* helper);
80 //! Callback for loading road objects into the list.
81 bool load(std::string tag, XML_Helper* helper);
83 //! A static pointer for the singleton instance.
84 static Roadlist* s_instance;