From 1c0240b5de2561704899508e555e2b88d852ffce Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 22 Oct 2012 13:48:11 +0800 Subject: [PATCH 1/4] fixed #1493: Added doxygen comments in CCNotificationCenter.h --- cocos2dx/support/CCNotificationCenter.cpp | 4 +- cocos2dx/support/CCNotificationCenter.h | 54 ++++++++++++++++++++--- 2 files changed, 50 insertions(+), 8 deletions(-) diff --git a/cocos2dx/support/CCNotificationCenter.cpp b/cocos2dx/support/CCNotificationCenter.cpp index 2fe860a129..0a9e63974e 100644 --- a/cocos2dx/support/CCNotificationCenter.cpp +++ b/cocos2dx/support/CCNotificationCenter.cpp @@ -29,7 +29,7 @@ THE SOFTWARE. using namespace std; -NS_CC_BEGIN; +NS_CC_BEGIN static CCNotificationCenter *s_sharedNotifCenter = NULL; @@ -214,4 +214,4 @@ CCObject *CCNotificationObserver::getObject() return m_object; } -NS_CC_END; +NS_CC_END diff --git a/cocos2dx/support/CCNotificationCenter.h b/cocos2dx/support/CCNotificationCenter.h index 183c5f7020..df0cd49cb5 100644 --- a/cocos2dx/support/CCNotificationCenter.h +++ b/cocos2dx/support/CCNotificationCenter.h @@ -28,38 +28,71 @@ THE SOFTWARE. #include "cocoa/CCObject.h" #include "cocoa/CCArray.h" -NS_CC_BEGIN; +NS_CC_BEGIN class CC_DLL CCNotificationCenter : public CCObject { public: + /* CCNotificationCenter constructor */ CCNotificationCenter(); + + /* CCNotificationCenter destructor */ ~CCNotificationCenter(); + /* Get the single instance of CCNotificationCenter. */ static CCNotificationCenter *sharedNotificationCenter(void); + + /* Destroy the single instance of CCNotificationCenter. */ static void purgeNotificationCenter(void); + /* @brief Add an observer for the specified target. + * @param target The target which want to be observed. + * @param selector The callback function which will be invoked when the specified notification event was posted. + * @param name The name of notification. + * @param obj The extra parameter which will be passed to the callback function. + */ void addObserver(CCObject *target, SEL_CallFuncO selector, const char *name, CCObject *obj); - + + /* @brief Remove the observer for the specified target. + * @param target The target which will not be observed any more. + * @param name The notification name which will not be observed any more. + */ void removeObserver(CCObject *target,const char *name); + /* @brief Register one hander for script binding. + * @note Only support Lua Binding now. + * @param handler The lua handler. + */ void registerScriptObserver(int handler); + + /* Unregister script observer */ void unregisterScriptObserver(void); + /* brief Post one notification event by name. + * param name The name of this notification. + */ void postNotification(const char *name); + + /* brief Post one notification event by name. + * param name The name of this notification. + * param object The extra parameter. + */ void postNotification(const char *name, CCObject *object); + /* brief Get script handler. + * note Only support Lua Binding now. + * return The script handle. + */ inline int getScriptHandler() { return m_scriptHandler; }; private: - // // internal functions - // + + // Check whether the observer exists by the specified target and name. bool observerExisted(CCObject *target,const char *name); - // // variables // CCArray *m_observers; @@ -69,12 +102,21 @@ private: class CC_DLL CCNotificationObserver : public CCObject { public: + /* brief Observer constructor + * @param target The target which want to be observed. + * @param selector The callback function which will be invoked when the specified notification event was posted. + * @param name The name of notification. + * @param obj The extra parameter which will be passed to the callback function. + */ CCNotificationObserver(CCObject *target, SEL_CallFuncO selector, const char *name, CCObject *obj); + + /* Observer destructor function */ ~CCNotificationObserver(); + /* Invoke the callback function of this observer */ void performSelector(CCObject *obj); private: CC_PROPERTY_READONLY(CCObject *, m_target, Target); @@ -83,6 +125,6 @@ private: CC_PROPERTY_READONLY(CCObject *, m_object, Object); }; -NS_CC_END; +NS_CC_END #endif//__CCNOTIFICATIONCENTER_H__ \ No newline at end of file From 6f4e56cd923c36828db15693b18b8e8c0c7c721c Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 22 Oct 2012 15:49:33 +0800 Subject: [PATCH 2/4] fixed #1493: Corrected some comments for CCNotificationCenter. --- cocos2dx/support/CCNotificationCenter.h | 62 ++++++++++++------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/cocos2dx/support/CCNotificationCenter.h b/cocos2dx/support/CCNotificationCenter.h index df0cd49cb5..c3aaea43ec 100644 --- a/cocos2dx/support/CCNotificationCenter.h +++ b/cocos2dx/support/CCNotificationCenter.h @@ -33,58 +33,58 @@ NS_CC_BEGIN class CC_DLL CCNotificationCenter : public CCObject { public: - /* CCNotificationCenter constructor */ + /** CCNotificationCenter constructor */ CCNotificationCenter(); - /* CCNotificationCenter destructor */ + /** CCNotificationCenter destructor */ ~CCNotificationCenter(); - /* Get the single instance of CCNotificationCenter. */ + /** Gets the single instance of CCNotificationCenter. */ static CCNotificationCenter *sharedNotificationCenter(void); - /* Destroy the single instance of CCNotificationCenter. */ + /** Destroys the single instance of CCNotificationCenter. */ static void purgeNotificationCenter(void); - /* @brief Add an observer for the specified target. - * @param target The target which want to be observed. - * @param selector The callback function which will be invoked when the specified notification event was posted. - * @param name The name of notification. - * @param obj The extra parameter which will be passed to the callback function. + /** @brief Adds an observer for the specified target. + * @param target The target which wants to observe notification events. + * @param selector The callback function which will be invoked when the specified notification event was posted. + * @param name The name of notification. + * @param obj The extra parameter which will be passed to the callback function. */ void addObserver(CCObject *target, SEL_CallFuncO selector, const char *name, CCObject *obj); - /* @brief Remove the observer for the specified target. - * @param target The target which will not be observed any more. - * @param name The notification name which will not be observed any more. + /** @brief Removes the observer by the specified target and name. + * @param target The target of this notification. + * @param name The name of this notification. */ void removeObserver(CCObject *target,const char *name); - /* @brief Register one hander for script binding. - * @note Only support Lua Binding now. - * @param handler The lua handler. + /** @brief Registers one hander for script binding. + * @note Only support Lua Binding now. + * @param handler The lua handler. */ void registerScriptObserver(int handler); - /* Unregister script observer */ + /** Unregisters script observer */ void unregisterScriptObserver(void); - /* brief Post one notification event by name. - * param name The name of this notification. + /** @brief Posts one notification event by name. + * @param name The name of this notification. */ void postNotification(const char *name); - /* brief Post one notification event by name. - * param name The name of this notification. - * param object The extra parameter. + /** @brief Posts one notification event by name. + * @param name The name of this notification. + * @param object The extra parameter. */ void postNotification(const char *name, CCObject *object); - /* brief Get script handler. - * note Only support Lua Binding now. - * return The script handle. + /** @brief Gets script handler. + * @note Only support Lua Binding now. + * @return The script handle. */ inline int getScriptHandler() { return m_scriptHandler; }; private: @@ -102,21 +102,21 @@ private: class CC_DLL CCNotificationObserver : public CCObject { public: - /* brief Observer constructor - * @param target The target which want to be observed. - * @param selector The callback function which will be invoked when the specified notification event was posted. - * @param name The name of notification. - * @param obj The extra parameter which will be passed to the callback function. + /** @brief CCNotificationObserver constructor + * @param target The target which wants to observer notification events. + * @param selector The callback function which will be invoked when the specified notification event was posted. + * @param name The name of this notification. + * @param obj The extra parameter which will be passed to the callback function. */ CCNotificationObserver(CCObject *target, SEL_CallFuncO selector, const char *name, CCObject *obj); - /* Observer destructor function */ + /** CCNotificationObserver destructor function */ ~CCNotificationObserver(); - /* Invoke the callback function of this observer */ + /** Invokes the callback function of this observer */ void performSelector(CCObject *obj); private: CC_PROPERTY_READONLY(CCObject *, m_target, Target); From 7af2f7c5ce2f7d4c037a07b55646acdfccd37abf Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 22 Oct 2012 15:51:06 +0800 Subject: [PATCH 3/4] fixed #1493: Updated one comment. --- cocos2dx/support/CCNotificationCenter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/support/CCNotificationCenter.h b/cocos2dx/support/CCNotificationCenter.h index c3aaea43ec..4dd28f471d 100644 --- a/cocos2dx/support/CCNotificationCenter.h +++ b/cocos2dx/support/CCNotificationCenter.h @@ -48,7 +48,7 @@ public: /** @brief Adds an observer for the specified target. * @param target The target which wants to observe notification events. * @param selector The callback function which will be invoked when the specified notification event was posted. - * @param name The name of notification. + * @param name The name of this notification. * @param obj The extra parameter which will be passed to the callback function. */ void addObserver(CCObject *target, From 56cdb7686756edeeb05d38a2210d1470f97f672e Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 22 Oct 2012 15:52:11 +0800 Subject: [PATCH 4/4] fixed #1493: Updated one comment. --- cocos2dx/support/CCNotificationCenter.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2dx/support/CCNotificationCenter.h b/cocos2dx/support/CCNotificationCenter.h index 4dd28f471d..4d7201fcb9 100644 --- a/cocos2dx/support/CCNotificationCenter.h +++ b/cocos2dx/support/CCNotificationCenter.h @@ -63,7 +63,7 @@ public: void removeObserver(CCObject *target,const char *name); /** @brief Registers one hander for script binding. - * @note Only support Lua Binding now. + * @note Only supports Lua Binding now. * @param handler The lua handler. */ void registerScriptObserver(int handler); @@ -83,7 +83,7 @@ public: void postNotification(const char *name, CCObject *object); /** @brief Gets script handler. - * @note Only support Lua Binding now. + * @note Only supports Lua Binding now. * @return The script handle. */ inline int getScriptHandler() { return m_scriptHandler; };