Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Obsevers {
- public:
- virtual ~Obsevers() {}
- };
- class TestObserver : public Obsevers {
- public:
- void print1(int i) {
- std::cout << i << std::endl;
- }
- };
- class TestObserver2 : public Obsevers {
- public:
- void print2(int i, char c) {
- std::cout << i << " , " << c << std::endl;
- }
- //possible new functions here later
- };
- template<typename Type, typename Notify>
- void NotifyObserver(Notify notify) {
- typedef std::list<Obsevers*>::iterator iter;
- iter it = m_observers.begin();
- iter end = m_observers.end();
- for(; it != end; ++it) {
- Type * o = dynamic_cast<Type*>(*it);
- if(o == NULL) continue;
- notify(o);
- }
- }
- NotifyObserver<TestObserver2>(boost::bind(&TestObserver2::print2, _1, 32, 'b'));
Add Comment
Please, Sign In to add comment