Cleaned up public interface of CCNodeLoaderLibrary (now takes either const char * or CCString, instead of std::string).

This commit is contained in:
Nicolas Gramlich 2012-06-14 01:16:54 -07:00
parent cdd1fb50ac
commit 4c6bf89167
4 changed files with 19 additions and 11 deletions

View File

@ -285,7 +285,7 @@ CCNode * CCBReader::readNodeGraph(CCNode * pParent) {
memberVarAssignmentName = this->readCachedString();
}
CCNodeLoader * ccNodeLoader = this->mCCNodeLoaderLibrary->getCCNodeLoader(className->m_sString);
CCNodeLoader * ccNodeLoader = this->mCCNodeLoaderLibrary->getCCNodeLoader(className);
CCNode * node = ccNodeLoader->loadCCNode(pParent, this);
/* Set root node, if not set yet. */

View File

@ -11,8 +11,8 @@
#define PROPERTY_IGNOREANCHORPOINTFORPOSITION "ignoreAnchorPointForPosition"
#define PROPERTY_VISIBLE "visible"
#define ASSERT_FAIL_UNEXPECTED_PROPERTY(PROPERTY) CCLOG("Unexpected property: '%s'!\n", PROPERTY->getCString()); assert(false)
#define ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(PROPERTYTYPE) CCLOG("Unexpected property type: '%d'!\n", PROPERTYTYPE); assert(false)
#define ASSERT_FAIL_UNEXPECTED_PROPERTY(PROPERTY) CCLog("Unexpected property: '%s'!\n", PROPERTY->getCString()); assert(false)
#define ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(PROPERTYTYPE) CCLog("Unexpected property type: '%d'!\n", PROPERTYTYPE); assert(false)
USING_NS_CC;
USING_NS_CC_EXT;

View File

@ -41,19 +41,24 @@ void CCNodeLoaderLibrary::registerDefaultCCNodeLoaders() {
this->registerCCNodeLoader("CCParticleSystemQuad", CCParticleSystemQuadLoader::loader());
}
void CCNodeLoaderLibrary::registerCCNodeLoader(std::string pClassName, CCNodeLoader * pCCNodeLoader) {
void CCNodeLoaderLibrary::registerCCNodeLoader(const char * pClassName, CCNodeLoader * pCCNodeLoader) {
pCCNodeLoader->retain();
this->mCCNodeLoaders.insert(std::pair<std::string, CCNodeLoader *>(pClassName, pCCNodeLoader));
}
void CCNodeLoaderLibrary::unregisterCCNodeLoader(std::string pClassName) {
std::map<std::string, CCNodeLoader *>::iterator ccNodeLoadersIterator = this->mCCNodeLoaders.find(pClassName);
void CCNodeLoaderLibrary::registerCCNodeLoader(CCString * pClassName, CCNodeLoader * pCCNodeLoader) {
pCCNodeLoader->retain();
this->mCCNodeLoaders.insert(std::pair<std::string, CCNodeLoader *>(pClassName->m_sString, pCCNodeLoader));
}
void CCNodeLoaderLibrary::unregisterCCNodeLoader(CCString * pClassName) {
std::map<std::string, CCNodeLoader *>::iterator ccNodeLoadersIterator = this->mCCNodeLoaders.find(pClassName->m_sString);
assert(ccNodeLoadersIterator != this->mCCNodeLoaders.end());
ccNodeLoadersIterator->second->release();
}
CCNodeLoader * CCNodeLoaderLibrary::getCCNodeLoader(std::string pClassName) {
std::map<std::string, CCNodeLoader *>::iterator ccNodeLoadersIterator = this->mCCNodeLoaders.find(pClassName);
CCNodeLoader * CCNodeLoaderLibrary::getCCNodeLoader(CCString * pClassName) {
std::map<std::string, CCNodeLoader *>::iterator ccNodeLoadersIterator = this->mCCNodeLoaders.find(pClassName->m_sString);
assert(ccNodeLoadersIterator != this->mCCNodeLoaders.end());
return ccNodeLoadersIterator->second;
}

View File

@ -17,9 +17,12 @@ class CC_DLL CCNodeLoaderLibrary : public CCObject {
~CCNodeLoaderLibrary();
void registerDefaultCCNodeLoaders();
void registerCCNodeLoader(std::string pClassName, CCNodeLoader * pCCNodeLoader);
void unregisterCCNodeLoader(std::string pClassName);
CCNodeLoader * getCCNodeLoader(std::string pClassName);
void registerCCNodeLoader(const char * pClassName, CCNodeLoader * pCCNodeLoader);
void registerCCNodeLoader(CCString * pClassName, CCNodeLoader * pCCNodeLoader);
void unregisterCCNodeLoader(const char * pClassName);
void unregisterCCNodeLoader(CCString * pClassName);
CCNodeLoader * getCCNodeLoader(const char * pClassName);
CCNodeLoader * getCCNodeLoader(CCString * pClassName);
void purge(bool pDelete);
public: