1 //  Copyright (C) 2007, 2008, 2009, 2014, 2020 Ben Asselstine
2 //
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.
7 //
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.
12 //
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
16 //  02110-1301, USA.
17 
18 #pragma once
19 #ifndef SIGNPOSTLIST_H
20 #define SIGNPOSTLIST_H
21 
22 #include <sigc++/trackable.h>
23 #include "LocationList.h"
24 #include "signpost.h"
25 
26 class XML_Helper;
27 
28 //! A list of Signpost objects on the game map.
29 /**
30  * The signpostlist keeps track of the signs located on the game map. It
31  * is implemented as a singleton because many classes use it for looking up
32  * signposts.
33  */
34 class Signpostlist : public LocationList<Signpost*>, public sigc::trackable
35 {
36     public:
37 	//! The xml tag of this object in a saved-game file.
38 	static Glib::ustring d_tag;
39 
40 	// Methods that operate on the class data but do not modify the class.
41 
42         //! Saves the signpost list to the opened saved-game file.
43         bool save(XML_Helper* helper) const;
44 
45         //! Count the number of signposts that have the default name.
46         guint32 countUnamedSignposts () const;
47 
48 	// Static Methods
49 
50         //! Return the singleton instance.  Create a new one if needed.
51         static Signpostlist* getInstance();
52 
53         //! Load the singleton instance loaded from the opened saved-game file.
54         static Signpostlist* getInstance(XML_Helper* helper);
55 
56         //! Explicitly delete the singleton instance.
57         static void deleteInstance();
58 
59     protected:
60         //! Default constructor.
61         Signpostlist();
62 
63         //! Loading constructor.
64 	/**
65 	 * @param helper  The opened saved-game file to load the signposts from.
66 	 */
67         Signpostlist(XML_Helper* helper);
68 
69     private:
70         //! Callback for loading signpost objects into the list.
71         bool load(Glib::ustring tag, XML_Helper* helper);
72 
73 	// DATA
74 
75         //! A static pointer for the singleton instance.
76         static Signpostlist* s_instance;
77 };
78 
79 #endif
80