CCEventCustom.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /****************************************************************************
  2. Copyright (c) 2013-2016 Chukong Technologies Inc.
  3. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  4. http://www.cocos2d-x.org
  5. Permission is hereby granted, free of charge, to any person obtaining a copy
  6. of this software and associated documentation files (the "Software"), to deal
  7. in the Software without restriction, including without limitation the rights
  8. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the Software is
  10. furnished to do so, subject to the following conditions:
  11. The above copyright notice and this permission notice shall be included in
  12. all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. THE SOFTWARE.
  20. ****************************************************************************/
  21. #ifndef __cocos2d_libs__CCCustomEvent__
  22. #define __cocos2d_libs__CCCustomEvent__
  23. #include <string>
  24. #include "base/CCEvent.h"
  25. /**
  26. * @addtogroup base
  27. * @{
  28. */
  29. NS_CC_BEGIN
  30. /** @class EventCustom
  31. * @brief Custom event.
  32. */
  33. class CC_DLL EventCustom : public Event
  34. {
  35. public:
  36. /** Constructor.
  37. *
  38. * @param eventName A given name of the custom event.
  39. * @js ctor
  40. */
  41. EventCustom(const std::string& eventName);
  42. /** Sets user data.
  43. *
  44. * @param data The user data pointer, it's a void*.
  45. */
  46. void setUserData(void* data) { _userData = data; }
  47. /** Gets user data.
  48. *
  49. * @return The user data pointer, it's a void*.
  50. */
  51. void* getUserData() const { return _userData; }
  52. /** Gets event name.
  53. *
  54. * @return The name of the event.
  55. */
  56. const std::string& getEventName() const { return _eventName; }
  57. protected:
  58. void* _userData; ///< User data
  59. std::string _eventName;
  60. };
  61. NS_CC_END
  62. // end of base group
  63. /// @}
  64. #endif /* defined(__cocos2d_libs__CCCustomEvent__) */