File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ Ref* ObjectFactory::createObject(const std::string &name)
65
65
if (t._fun != nullptr ) {
66
66
return t._fun ();
67
67
}
68
- else if (t._func != nullptr ) {
68
+ if (t._func != nullptr ) {
69
69
return t._func ();
70
70
}
71
71
return nullptr ;
@@ -76,4 +76,9 @@ void ObjectFactory::registerType(const TInfo &t)
76
76
_typeMap.emplace (t._class , t);
77
77
}
78
78
79
+ void ObjectFactory::removeAll ()
80
+ {
81
+ _typeMap.clear ();
82
+ }
83
+
79
84
NS_CC_END
Original file line number Diff line number Diff line change @@ -48,12 +48,11 @@ class CC_DLL ObjectFactory
48
48
Instance _fun = nullptr ;
49
49
InstanceFunc _func;
50
50
};
51
- typedef std::unordered_map<std::string, TInfo> FactoryMap;
52
51
53
52
static ObjectFactory* getInstance ();
54
53
static void destroyInstance ();
55
- cocos2d::Ref* createObject (const std::string &name);
56
54
55
+ cocos2d::Ref* createObject (const std::string &name);
57
56
void registerType (const TInfo &t);
58
57
void removeAll ();
59
58
@@ -62,7 +61,7 @@ class CC_DLL ObjectFactory
62
61
virtual ~ObjectFactory () = default ;
63
62
private:
64
63
static ObjectFactory *_sharedFactory;
65
- FactoryMap _typeMap;
64
+ std::unordered_map<std::string, TInfo> _typeMap;
66
65
};
67
66
68
67
NS_CC_END
You can’t perform that action at this time.
0 commit comments