Debian Codegraph @

include/ifavourites.h

raw
1 #pragma once
2
3 #include <set>
4 #include <sigc++/signal.h>
5 #include "imodule.h"
6
7 namespace game
8 {
9
10 /**
11 * Favourite Management interface keeping track of resources
12 * that have been tagged as favourite by the user.
13 *
14 * Each favourite obejct has a typename and a (unique) identifier.
15 * The typename is treated case-insensitively - it is used as tag identifier
16 * when persisting the set, therefore it must consist of word characters only.
17 */
18 class IFavouritesManager :
19 public RegisterableModule
20 {
21 public:
22 virtual ~IFavouritesManager() {}
23
24 /**
25 * Adds the given favourite object to the set of favourites
26 *
27 * @typeName: Type name of the favourite, like "prefab" or "material"
28 * Favourites with the same type name are grouped.
29 *
30 * @identifier: The identifier of this favourite object,
31 * like a file path or a declaration name
32 */
33 virtual void addFavourite(const std::string& typeName, const std::string& identifier) = 0;
34
35 // Removes the favourite with the given type and identifier from the set of favourites
36 virtual void removeFavourite(const std::string& typeName, const std::string& identifier) = 0;
37
38 // Returns true if the given type/name combination is listed as favourite
39 virtual bool isFavourite(const std::string& typeName, const std::string& identifier) = 0;
40
41 // Returns the whole set of favourites for the given type name
42 virtual std::set<std::string> getFavourites(const std::string& typeName) = 0;
43
44 // Returns the changed signal for the given type - will be fired when the set changes
45 // Requesting a signal for an empty typename will trigger a std::invalid_argument exception
46 virtual sigc::signal<void>& getSignalForType(const std::string& typeName) = 0;
47 };
48
49 }
50
51 constexpr const char* const MODULE_FAVOURITES_MANAGER("FavouritesManager");
52
53 inline game::IFavouritesManager& GlobalFavouritesManager()
54 {
55 static module::InstanceReference<game::IFavouritesManager> _reference(MODULE_FAVOURITES_MANAGER);
56 return _reference;
57 }
58