cocos2d-x  3.2
 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 More...
 
 ~__NotificationCenter ()
 __NotificationCenter destructor 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 ()

Static Public Member Functions

static __NotificationCentergetInstance ()
 Gets the single instance of __NotificationCenter. More...
 
local getInstance ()
 Gets the single instance of __NotificationCenter. More...
 
static void destroyInstance ()
 Destroys the single instance of __NotificationCenter. More...
 
static __NotificationCentersharedNotificationCenter (void)
local sharedNotificationCenter ()
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

var ctor ( )

__NotificationCenter constructor

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.
var addObserver ( var  target,
var  selector,
var  name,
var  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.
local addObserver ( local  target,
local  selector,
local  name,
local  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.

var destroyInstance ( )
static

Destroys the single instance of __NotificationCenter.

local destroyInstance ( )
static

Destroys the single instance of __NotificationCenter.

static __NotificationCenter*
getInstance
( )
static

Gets the single instance of __NotificationCenter.

var getInstance ( )
static

Gets the single instance of __NotificationCenter.

local 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.
var getObserverHandlerByName ( var  name)

Gets observer script handler.

Parameters
nameThe name of this notification.
Returns
The observer script handle.
local getObserverHandlerByName ( local  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.
var getScriptHandler ( )
inline

Gets script handler.

Note
Only supports Lua Binding now.
Returns
The script handle.
local getScriptHandler ( )
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.
var postNotification ( var  name)

Posts one notification event by name.

Parameters
nameThe name of this notification.
local postNotification ( local  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
var postNotification ( var  name,
var  sender 
)

Posts one notification event by name.

Parameters
nameThe name of this notification.
senderThe object posting the notification. Can be nullptr
local postNotification ( local  name,
local  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
var purgeNotificationCenter (   )
static
local purgeNotificationCenter (   )
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.
var registerScriptObserver ( var  target,
var  handler,
var  name 
)

Registers one hander for script binding.

Note
Only supports Lua Binding now.
Parameters
handlerThe lua handler.
local registerScriptObserver ( local  target,
local  handler,
local  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
var removeAllObservers ( var  target)

Removes all notifications registered by this target.

Parameters
targetThe target of this notification.
Returns
the number of observers removed
local removeAllObservers ( local  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.
var removeObserver ( var  target,
var  name 
)

Removes the observer by the specified target and name.

Parameters
targetThe target of this notification.
nameThe name of this notification.
local removeObserver ( local  target,
local  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
var sharedNotificationCenter (   )
static
local sharedNotificationCenter (   )
static
void unregisterScriptObserver ( Ref target,
const std::string &  name 
)

Unregisters script observer.

var unregisterScriptObserver ( var  target,
var  name 
)

Unregisters script observer.

local unregisterScriptObserver ( local  target,
local  name 
)

Unregisters script observer.

Friends And Related Function Documentation

friend class ScriptHandlerMgr
friend
var ScriptHandlerMgr
friend
local ScriptHandlerMgr
friend

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