CCNodeLoaderLibrary.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /****************************************************************************
  2. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  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 _CCB_CCNODELOADERLIBRARY_H_
  21. #define _CCB_CCNODELOADERLIBRARY_H_
  22. #include "editor-support/cocosbuilder/CCBReader.h"
  23. namespace cocosbuilder {
  24. class NodeLoader;
  25. typedef std::map<std::string, NodeLoader *> NodeLoaderMap;
  26. typedef std::pair<std::string, NodeLoader *> NodeLoaderMapEntry;
  27. class CC_DLL NodeLoaderLibrary : public cocos2d::Ref
  28. {
  29. public:
  30. /**
  31. * @js NA
  32. * @lua NA
  33. */
  34. CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(NodeLoaderLibrary, library);
  35. /**
  36. * @js NA
  37. * @lua NA
  38. */
  39. NodeLoaderLibrary();
  40. /**
  41. * @js NA
  42. * @lua NA
  43. */
  44. virtual ~NodeLoaderLibrary();
  45. /**
  46. * @js NA
  47. * @lua NA
  48. */
  49. void registerDefaultNodeLoaders();
  50. /**
  51. * @js NA
  52. * @lua NA
  53. */
  54. void registerNodeLoader(const char * pClassName, NodeLoader * pNodeLoader);
  55. //void registerNodeLoader(String * pClassName, NodeLoader * pNodeLoader);
  56. /**
  57. * @js NA
  58. * @lua NA
  59. */
  60. void unregisterNodeLoader(const char * pClassName);
  61. //void unregisterNodeLoader(String * pClassName);
  62. /**
  63. * @js NA
  64. * @lua NA
  65. */
  66. NodeLoader * getNodeLoader(const char * pClassName);
  67. //CCNodeLoader * getNodeLoader(String * pClassName);
  68. /**
  69. * @js NA
  70. * @lua NA
  71. */
  72. void purge(bool pDelete);
  73. /**
  74. * @js NA
  75. * @lua NA
  76. */
  77. CC_DEPRECATED_ATTRIBUTE void registerDefaultCCNodeLoaders() { registerDefaultNodeLoaders(); }
  78. /**
  79. * @js NA
  80. * @lua NA
  81. */
  82. CC_DEPRECATED_ATTRIBUTE void registerCCNodeLoader(const char * pClassName, NodeLoader * pNodeLoader) { registerNodeLoader(pClassName, pNodeLoader); };
  83. /**
  84. * @js NA
  85. * @lua NA
  86. */
  87. CC_DEPRECATED_ATTRIBUTE void unregisterCCNodeLoader(const char * pClassName) { unregisterNodeLoader(pClassName); };
  88. /**
  89. * @js NA
  90. * @lua NA
  91. */
  92. CC_DEPRECATED_ATTRIBUTE NodeLoader * getCCNodeLoader(const char * pClassName) { return getNodeLoader(pClassName); };
  93. public:
  94. /**
  95. * @js NA
  96. * @lua NA
  97. */
  98. static NodeLoaderLibrary * getInstance();
  99. /**
  100. * @js NA
  101. * @lua NA
  102. */
  103. static void destroyInstance();
  104. /**
  105. * @js NA
  106. * @lua NA
  107. */
  108. static NodeLoaderLibrary * newDefaultNodeLoaderLibrary();
  109. /**
  110. * @js NA
  111. * @lua NA
  112. */
  113. CC_DEPRECATED_ATTRIBUTE static NodeLoaderLibrary * sharedNodeLoaderLibrary() { return NodeLoaderLibrary::getInstance(); };
  114. /**
  115. * @js NA
  116. * @lua NA
  117. */
  118. CC_DEPRECATED_ATTRIBUTE static void purgeSharedNodeLoaderLibrary() { NodeLoaderLibrary::destroyInstance(); };
  119. /**
  120. * @js NA
  121. * @lua NA
  122. */
  123. CC_DEPRECATED_ATTRIBUTE static NodeLoaderLibrary * newDefaultCCNodeLoaderLibrary() { return NodeLoaderLibrary::newDefaultNodeLoaderLibrary(); };
  124. private:
  125. NodeLoaderMap _nodeLoaders;
  126. };
  127. }
  128. #endif