123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- #ifndef __CCNOTIFICATIONCENTER_H__
- #define __CCNOTIFICATIONCENTER_H__
- #include "base/CCRef.h"
- #include "base/ccTypes.h"
- NS_CC_BEGIN
- class __Array;
- class ScriptHandlerMgr;
- class CC_DLL __NotificationCenter : public Ref
- {
- friend class ScriptHandlerMgr;
- public:
-
- __NotificationCenter();
-
- ~__NotificationCenter();
-
-
- static __NotificationCenter *getInstance();
-
- static void destroyInstance();
-
- CC_DEPRECATED_ATTRIBUTE static __NotificationCenter *sharedNotificationCenter(void);
-
- CC_DEPRECATED_ATTRIBUTE static void purgeNotificationCenter(void);
-
- void addObserver(Ref *target,
- SEL_CallFuncO selector,
- const std::string& name,
- Ref *sender);
-
- void removeObserver(Ref *target,const std::string& name);
-
-
- int removeAllObservers(Ref *target);
-
- void registerScriptObserver(Ref *target,int handler,const std::string& name);
-
- void unregisterScriptObserver(Ref *target,const std::string& name);
-
-
- void postNotification(const std::string& name);
-
- void postNotification(const std::string& name, Ref *sender);
-
-
- int getScriptHandler() const { return _scriptHandler; }
-
-
- int getObserverHandlerByName(const std::string& name);
- private:
-
-
- bool observerExisted(Ref *target,const std::string& name, Ref *sender);
-
-
-
- __Array *_observers;
- int _scriptHandler;
- };
- class CC_DLL NotificationObserver : public Ref
- {
- public:
-
- NotificationObserver(Ref *target,
- SEL_CallFuncO selector,
- const std::string& name,
- Ref *sender);
-
- ~NotificationObserver();
-
-
- void performSelector(Ref *sender);
-
-
-
- Ref* getTarget() const;
-
- SEL_CallFuncO getSelector() const;
-
- const std::string& getName() const;
-
- Ref* getSender() const;
-
- int getHandler() const;
-
- void setHandler(int handler);
- private:
- Ref* _target;
- SEL_CallFuncO _selector;
- std::string _name;
- Ref* _sender;
- int _handler;
- };
- NS_CC_END
- #endif
|