44 #include "../../components_h.h"
46 #include "../../components.h"
51 static vector<ComponentListEntry>* componentListRunTime = NULL;
56 string (*getAttributeFunc)(
const string& attributeName))
66 if (componentListRunTime == NULL)
67 componentListRunTime =
new vector<ComponentListEntry>();
74 componentListRunTime->push_back(cle);
82 delete componentListRunTime;
83 componentListRunTime = NULL;
88 const string& componentNameAndOptionalArgs,
GXemul* gxemul)
95 if (p != string::npos && p > 0) {
98 string argstring = componentNameAndOptionalArgs.substr(p+1);
101 if (argstring[argstring.length()-1] !=
')') {
108 argstring = argstring.substr(0, argstring.length()-1);
116 for (
size_t i=0; i<assignments.size(); ++i) {
118 if (keyAndValue.size() != 2) {
134 #ifndef UNSTABLE_DEVEL
138 return componentList[i].
Create(args);
143 for (i=0; componentListRunTime != NULL && i<componentListRunTime->size(); ++i) {
145 #ifndef UNSTABLE_DEVEL
146 && !(*componentListRunTime)[i].
GetAttribute(
"stable").empty()
149 return (*componentListRunTime)[i].Create(args);
164 const string& key = it->first;
165 const string& value = it->second;
168 if (createArgs.
gxemul != NULL) {
170 ss <<
"Unknown setting '" << key <<
"'. "
171 "Available settings (with default values) are:\n";
172 for (ComponentCreationSettings::const_iterator it2 = defaultSettings.begin();
173 it2 != defaultSettings.end(); ++it2)
174 ss <<
" " << it2->first <<
" = " << it2->second <<
"\n";
190 const string& attributeName)
200 for (i=0; componentListRunTime!=NULL && i<componentListRunTime->size(); ++i) {
202 return (*componentListRunTime)[i].GetAttribute(
211 const string& attributeName)
219 vector<string> result;
223 if ((!onlyTemplates ||
225 #ifndef UNSTABLE_DEVEL
233 for (i=0; componentListRunTime!=NULL && i<componentListRunTime->size(); ++i) {
234 if ((!onlyTemplates ||
235 (*componentListRunTime)[i].
GetAttribute(
"template") ==
"yes")
236 #ifndef UNSTABLE_DEVEL
237 && !(*componentListRunTime)[i].
GetAttribute(
"stable").empty()
252 static void Test_ComponentFactory_Nonexistant()
257 component.
IsNULL() ==
true);
260 static void Test_ComponentFactory_SimpleDummy()
265 component.
IsNULL() ==
false);
273 static void Test_ComponentFactory_FromTemplate()
278 component.
IsNULL() ==
false);
295 static void Test_ComponentFactory_HasAttribute()
312 UNITTEST(Test_ComponentFactory_Nonexistant);
313 UNITTEST(Test_ComponentFactory_SimpleDummy);
314 UNITTEST(Test_ComponentFactory_FromTemplate);
315 UNITTEST(Test_ComponentFactory_HasAttribute);