-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added: Message_manager to notify changes in zoom (trying to recompute…
… the country boundaries results in strange OpenGL problems)
- Loading branch information
1 parent
92c6c17
commit 13111f4
Showing
7 changed files
with
93 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
#include "Message_manager.h" | ||
|
||
|
||
std::map<std::string, Message_manager::Callbacks> | ||
Message_manager::s_message_map; | ||
|
||
|
||
void Message_manager::add(const std::string& msg_name, | ||
std::function<void()> callback) | ||
{ | ||
s_message_map[msg_name].push_back(callback); | ||
} | ||
|
||
void Message_manager::notify_all(const std::string& msg_name) | ||
{ | ||
auto it = s_message_map.find(msg_name); | ||
if (s_message_map.cend() != it) | ||
{ | ||
auto& callbacks = it->second; | ||
for (auto& cb : callbacks) | ||
cb(); | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
#ifndef MESSAGE_MANAGER_H | ||
#define MESSAGE_MANAGER_H | ||
|
||
#include <functional> | ||
#include <map> | ||
#include <string> | ||
|
||
|
||
class Message_manager | ||
{ | ||
public: | ||
static void add(const std::string& msg_name, std::function<void()> callback); | ||
static void notify_all(const std::string& msg_name); | ||
|
||
protected: | ||
using Callbacks = std::vector<std::function<void()>>; | ||
static std::map<std::string, Callbacks> s_message_map; | ||
|
||
}; | ||
|
||
|
||
#endif |