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 return componentList[i].
Create(args);
139 for (i=0; componentListRunTime != NULL && i<componentListRunTime->size(); ++i) {
141 return (*componentListRunTime)[i].Create(args);
159 const string& key = it->first;
160 const string& value = it->second;
163 if (createArgs.
gxemul != NULL) {
165 ss <<
"Unknown setting '" << key <<
"'. "
166 "Available settings (with default values) are:\n";
167 for (ComponentCreationSettings::const_iterator it2 = defaultSettings.begin();
168 it2 != defaultSettings.end(); ++it2)
169 ss <<
" " << it2->first <<
" = " << it2->second <<
"\n";
185 const string& attributeName)
195 for (i=0; componentListRunTime!=NULL && i<componentListRunTime->size(); ++i) {
197 return (*componentListRunTime)[i].GetAttribute(
206 const string& attributeName)
214 vector<string> result;
218 if ((!onlyTemplates ||
224 for (i=0; componentListRunTime!=NULL && i<componentListRunTime->size(); ++i) {
225 if ((!onlyTemplates ||
226 (*componentListRunTime)[i].
GetAttribute(
"template") ==
"yes"))
239 static void Test_ComponentFactory_Nonexistant()
244 component.
IsNULL() ==
true);
247 static void Test_ComponentFactory_SimpleDummy()
252 component.
IsNULL() ==
false);
260 static void Test_ComponentFactory_FromTemplate()
265 component.
IsNULL() ==
false);
282 static void Test_ComponentFactory_HasAttribute()
296 UNITTEST(Test_ComponentFactory_Nonexistant);
297 UNITTEST(Test_ComponentFactory_SimpleDummy);
298 UNITTEST(Test_ComponentFactory_FromTemplate);
299 UNITTEST(Test_ComponentFactory_HasAttribute);