cocos2d-x  3.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
__NotificationCenter Class Reference

#include <CCNotificationCenter.h>

Inheritance diagram for __NotificationCenter:
Ref

Public Member Functions

 __NotificationCenter ()
 __NotificationCenter constructor ctor More...
 
 ~__NotificationCenter ()
 __NotificationCenter destructor NA NA More...
 
void addObserver (Ref *target, SEL_CallFuncO selector, const std::string &name, Ref *sender)
 Adds an observer for the specified target. More...
 
void removeObserver (Ref *target, const std::string &name)
 Removes the observer by the specified target and name. More...
 
int removeAllObservers (Ref *target)
 Removes all notifications registered by this target. More...
 
void registerScriptObserver (Ref *target, int handler, const std::string &name)
 Registers one hander for script binding. More...
 
void unregisterScriptObserver (Ref *target, const std::string &name)
 Unregisters script observer. More...
 
void postNotification (const std::string &name)
 Posts one notification event by name. More...
 
void postNotification (const std::string &name, Ref *sender)
 Posts one notification event by name. More...
 
int getScriptHandler () const
 Gets script handler. More...
 
int getObserverHandlerByName (const std::string &name)
 Gets observer script handler. More...
 
- Public Member Functions inherited from Ref
void retain ()
 Retains the ownership. More...
 
void release ()
 Releases the ownership immediately. More...
 
Refautorelease ()
 Releases the ownership sometime soon automatically. More...
 
unsigned int getReferenceCount () const
 Returns the Ref's current reference count. More...
 
virtual ~Ref ()
 NA NA More...
 

Static Public Member Functions

static __NotificationCentergetInstance ()
 Gets the single instance of __NotificationCenter. More...
 
static void destroyInstance ()
 Destroys the single instance of __NotificationCenter. More...
 
static __NotificationCentersharedNotificationCenter (void)
 
static void purgeNotificationCenter (void)
 

Friends

class ScriptHandlerMgr
 

Additional Inherited Members

- Protected Member Functions inherited from Ref
 Ref ()
 Constructor. More...
 
- Protected Attributes inherited from Ref
unsigned int _referenceCount
 count of references More...
 

Constructor & Destructor Documentation

Member Function Documentation

void addObserver ( Ref target,
SEL_CallFuncO  selector,
const std::string &  name,
Ref sender 
)

Adds an observer for the specified target.

Parameters
targetThe target which wants to observe notification events.
selectorThe callback function which will be invoked when the specified notification event was posted.
nameThe name of this notification.
senderThe object whose notifications the target wants to receive. Only notifications sent by this sender are delivered to the target. nullptr means that the sender is not used to decide whether to deliver the notification to target.
static void destroyInstance ( )
static

Destroys the single instance of __NotificationCenter.

static __NotificationCenter* getInstance ( )
static

Gets the single instance of __NotificationCenter.

int getObserverHandlerByName ( const std::string &  name)

Gets observer script handler.

Parameters
nameThe name of this notification.
Returns
The observer script handle.
int getScriptHandler ( ) const
inline

Gets script handler.

Note
Only supports Lua Binding now.
Returns
The script handle.
void postNotification ( const std::string &  name)

Posts one notification event by name.

Parameters
nameThe name of this notification.
void postNotification ( const std::string &  name,
Ref sender 
)

Posts one notification event by name.

Parameters
nameThe name of this notification.
senderThe object posting the notification. Can be nullptr
static void purgeNotificationCenter ( void  )
static
void registerScriptObserver ( Ref target,
int  handler,
const std::string &  name 
)

Registers one hander for script binding.

Note
Only supports Lua Binding now.
Parameters
handlerThe lua handler.
int removeAllObservers ( Ref target)

Removes all notifications registered by this target.

Parameters
targetThe target of this notification.
Returns
the number of observers removed
void removeObserver ( Ref target,
const std::string &  name 
)

Removes the observer by the specified target and name.

Parameters
targetThe target of this notification.
nameThe name of this notification.
static __NotificationCenter* sharedNotificationCenter ( void  )
static
void unregisterScriptObserver ( Ref target,
const std::string &  name 
)

Unregisters script observer.

Friends And Related Function Documentation

friend class ScriptHandlerMgr
friend

The documentation for this class was generated from the following file: