Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/diegostamigni/notification_center
A simple C++1x implementation of the NSNotificationCenter
https://github.com/diegostamigni/notification_center
Last synced: about 2 months ago
JSON representation
A simple C++1x implementation of the NSNotificationCenter
- Host: GitHub
- URL: https://github.com/diegostamigni/notification_center
- Owner: diegostamigni
- Created: 2015-12-11T12:10:17.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-12-11T13:32:56.000Z (about 9 years ago)
- Last Synced: 2023-04-03T17:46:47.801Z (almost 2 years ago)
- Language: C++
- Homepage: http://www.diegostamigni.com
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# notification_center
### MIT LicenseThis is a simple implementation of a [NSNotificationCenter](https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSNotificationCenter_Class) using the C++ (11/14) STL APIs. Pull requests are appreciated.
#####Usage:
```c++
#include "notification_center.h"
#includestruct Test : ds::Observable {
// Requested by the Observable abstract class in order to
// correctly dispatch the message
void operator()(const ds::Notification ¬ification) const override {
auto obj = notification.get_object();
if (obj != nullptr) {
// we **MUST** know it's type, at least for now..
std::cout << notification.get_tag()
<< ": "
<< (char *)obj
<< std::endl;
}
}
};int main(int argc, char **argv) {
auto t = std::string {"Test Object"};
auto test = std::make_shared ();
auto nc = ds::NotificationCenter::instance();
nc->AddObserver("NotificationTag", test);
nc->PostNotification("NotificationTag", t.c_str());
return 0;
}
```