MCPcopy Create free account
hub / github.com/JSBSim-Team/jsbsim / Load

Method Load

src/math/FGFunction.cpp:315–948  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

313//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
314
315void FGFunction::Load(Element* el, FGPropertyValue* var, FGFDMExec* fdmex,
316 const string& Prefix)
317{
318 Name = el->GetAttributeValue("name");
319 Element* element = el->GetElement();
320
321 auto sum = [](const decltype(Parameters)& Parameters)->double {
322 double temp = 0.0;
323
324 for (auto p: Parameters)
325 temp += p->GetValue();
326
327 return temp;
328 };
329
330 while (element) {
331 string operation = element->GetName();
332
333 // data types
334 if (operation == "property" || operation == "p") {
335 string property_name = element->GetDataLine();
336
337 if (var && simgear::strutils::strip(property_name) == "#")
338 Parameters.push_back(var);
339 else {
340 if (property_name.find("#") != string::npos) {
341 if (is_number(Prefix)) {
342 property_name = replace(property_name,"#",Prefix);
343 }
344 else {
345 XMLLogException err(element);
346 err << LogFormat::RED << "Illegal use of the special character '#'\n"
347 << LogFormat::RESET;
348 throw err;
349 }
350 }
351
352 if (element->HasAttribute("apply")) {
353 string function_str = element->GetAttributeValue("apply");
354 auto f = fdmex->GetTemplateFunc(function_str);
355 if (f)
356 Parameters.push_back(new FGFunctionValue(property_name,
357 PropertyManager, f, element));
358 else {
359 FGXMLLogging log(element, LogLevel::ERROR);
360 log << LogFormat::RED << LogFormat::BOLD
361 << " No function by the name " << function_str
362 << " has been defined. This property will "
363 << "not be logged. You should check your configuration file.\n"
364 << LogFormat::RESET;
365 }
366 }
367 else
368 Parameters.push_back(new FGPropertyValue(property_name,
369 PropertyManager, element));
370 }
371 } else if (operation == "value" || operation == "v") {
372 Parameters.push_back(new FGRealValue(element->GetDataAsNumber()));

Callers

nothing calls this directly

Calls 15

stripFunction · 0.85
is_numberFunction · 0.85
replaceFunction · 0.85
GetBinaryFunction · 0.85
make_MathFnFunction · 0.85
atof_locale_cFunction · 0.85
makeRandomGeneratorFunction · 0.85
GetAttributeValueMethod · 0.80
GetDataLineMethod · 0.80
GetDataAsNumberMethod · 0.80
sizeMethod · 0.80
ReadFromMethod · 0.80

Tested by

no test coverage detected