2018-01-29 16:25:32 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2012-06-13 02:59:49 +08:00
|
|
|
#ifndef _CCB_CCNODELOADERLIBRARY_H_
|
|
|
|
#define _CCB_CCNODELOADERLIBRARY_H_
|
2012-06-06 08:15:28 +08:00
|
|
|
|
2016-03-20 21:53:44 +08:00
|
|
|
#include "editor-support/cocosbuilder/CCBReader.h"
|
2012-06-06 08:15:28 +08:00
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
namespace cocosbuilder {
|
2012-06-06 08:15:28 +08:00
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
class NodeLoader;
|
2012-09-24 11:47:33 +08:00
|
|
|
|
2013-06-20 14:15:53 +08:00
|
|
|
typedef std::map<std::string, NodeLoader *> NodeLoaderMap;
|
|
|
|
typedef std::pair<std::string, NodeLoader *> NodeLoaderMapEntry;
|
2012-06-15 04:51:32 +08:00
|
|
|
|
2014-08-27 10:18:44 +08:00
|
|
|
class CC_DLL NodeLoaderLibrary : public cocos2d::Ref
|
2013-07-27 22:31:57 +08:00
|
|
|
{
|
2013-07-24 18:00:02 +08:00
|
|
|
public:
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-07-24 18:00:02 +08:00
|
|
|
CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(NodeLoaderLibrary, library);
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-07-24 18:00:02 +08:00
|
|
|
NodeLoaderLibrary();
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-07-24 18:00:02 +08:00
|
|
|
virtual ~NodeLoaderLibrary();
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-07-24 18:00:02 +08:00
|
|
|
void registerDefaultNodeLoaders();
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-07-24 18:00:02 +08:00
|
|
|
void registerNodeLoader(const char * pClassName, NodeLoader * pNodeLoader);
|
|
|
|
//void registerNodeLoader(String * pClassName, NodeLoader * pNodeLoader);
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-07-24 18:00:02 +08:00
|
|
|
void unregisterNodeLoader(const char * pClassName);
|
|
|
|
//void unregisterNodeLoader(String * pClassName);
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-07-24 18:00:02 +08:00
|
|
|
NodeLoader * getNodeLoader(const char * pClassName);
|
|
|
|
//CCNodeLoader * getNodeLoader(String * pClassName);
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-07-24 18:00:02 +08:00
|
|
|
void purge(bool pDelete);
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-07-24 18:00:02 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE void registerDefaultCCNodeLoaders() { registerDefaultNodeLoaders(); }
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-07-24 18:00:02 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE void registerCCNodeLoader(const char * pClassName, NodeLoader * pNodeLoader) { registerNodeLoader(pClassName, pNodeLoader); };
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-07-24 18:00:02 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE void unregisterCCNodeLoader(const char * pClassName) { unregisterNodeLoader(pClassName); };
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-07-25 10:33:19 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE NodeLoader * getCCNodeLoader(const char * pClassName) { return getNodeLoader(pClassName); };
|
2013-07-24 18:00:02 +08:00
|
|
|
|
|
|
|
public:
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-07-24 18:00:02 +08:00
|
|
|
static NodeLoaderLibrary * getInstance();
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-07-24 18:00:02 +08:00
|
|
|
static void destroyInstance();
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-07-24 18:00:02 +08:00
|
|
|
static NodeLoaderLibrary * newDefaultNodeLoaderLibrary();
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-07-24 18:00:02 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE static NodeLoaderLibrary * sharedNodeLoaderLibrary() { return NodeLoaderLibrary::getInstance(); };
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-07-24 18:00:02 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE static void purgeSharedNodeLoaderLibrary() { NodeLoaderLibrary::destroyInstance(); };
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-07-24 18:00:02 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE static NodeLoaderLibrary * newDefaultCCNodeLoaderLibrary() { return NodeLoaderLibrary::newDefaultNodeLoaderLibrary(); };
|
2013-07-27 22:31:57 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
NodeLoaderMap _nodeLoaders;
|
2012-06-06 08:15:28 +08:00
|
|
|
};
|
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
}
|
2012-06-06 08:15:28 +08:00
|
|
|
|
|
|
|
#endif
|