1
0

CCEventCustom.h 2.3 KB

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