SuperTuxKart
favorite_status.hpp
1 //
2 // SuperTuxKart - a fun racing game with go-kart
3 // Copyright (C) 2024 SuperTuxKart-Team
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 3
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 
19 #ifndef HEADER_FAVORITE_STATUS_HPP
20 #define HEADER_FAVORITE_STATUS_HPP
21 
22 #include "utils/leak_check.hpp"
23 
24 #include <irrString.h>
25 
26 #include <set>
27 #include <string>
28 #include <unordered_map>
29 
30 using namespace irr;
31 
33 class TrackManager;
34 class UTFWriter;
35 class XMLNode;
36 
43 {
44 private:
45  LEAK_CHECK()
46 
47  std::string m_parse_type;
48 
50  std::unordered_map<std::string, std::set<std::string> > m_favorite;
51 
52 public:
53  static const std::string DEFAULT_FAVORITE_GROUP_NAME;
54 
56  FavoriteStatus(const XMLNode *node, std::string parse_type);
57 
58  void save(UTFWriter &out);
59 
60  bool isFavorite(std::string ident);
61 
62  void addFavorite(std::string ident, std::string group = DEFAULT_FAVORITE_GROUP_NAME);
63 
64  void removeFavorite(std::string ident, std::string group = DEFAULT_FAVORITE_GROUP_NAME);
65 
66  const std::unordered_map<std::string, std::set<std::string> >& getAllFavorites() const
67  { return m_favorite; }
68 }; // class FavoriteStatus
69 
70 #endif
71 
72 /*EOF*/
Class for storing the current favorites/custom groups of karts and tracks.
Definition: favorite_status.hpp:43
std::unordered_map< std::string, std::set< std::string > > m_favorite
unordered_map<Group Name, set<Track Name> > .
Definition: favorite_status.hpp:50
Definition: kart_properties_manager.hpp:42
Simple class to load and manage track data, track names and such.
Definition: track_manager.hpp:35
utility class used to write wide (UTF-16 or UTF-32, depending of size of wchar_t) XML files
Definition: utf_writer.hpp:35
utility class used to parse XML files
Definition: xml_node.hpp:48