36 #include "FGFunction.h" 38 #include "FGPropertyValue.h" 39 #include "FGRealValue.h" 40 #include "input_output/FGXMLElement.h" 46 IDENT(IdSrc,
"$Id: FGFunction.cpp,v 1.58 2015/07/12 19:34:08 bcoconni Exp $");
47 IDENT(IdHdr,ID_FUNCTION);
53 const std::string FGFunction::property_string =
"property";
54 const std::string FGFunction::value_string =
"value";
55 const std::string FGFunction::table_string =
"table";
56 const std::string FGFunction::p_string =
"p";
57 const std::string FGFunction::v_string =
"v";
58 const std::string FGFunction::t_string =
"t";
60 const std::string FGFunction::function_string =
"function";
61 const std::string FGFunction::description_string =
"description";
62 const std::string FGFunction::sum_string =
"sum";
63 const std::string FGFunction::difference_string =
"difference";
64 const std::string FGFunction::product_string =
"product";
65 const std::string FGFunction::quotient_string =
"quotient";
66 const std::string FGFunction::pow_string =
"pow";
67 const std::string FGFunction::sqrt_string =
"sqrt";
68 const std::string FGFunction::toradians_string =
"toradians";
69 const std::string FGFunction::todegrees_string =
"todegrees";
70 const std::string FGFunction::exp_string =
"exp";
71 const std::string FGFunction::log2_string =
"log2";
72 const std::string FGFunction::ln_string =
"ln";
73 const std::string FGFunction::log10_string =
"log10";
74 const std::string FGFunction::abs_string =
"abs";
75 const std::string FGFunction::sign_string =
"sign";
76 const std::string FGFunction::sin_string =
"sin";
77 const std::string FGFunction::cos_string =
"cos";
78 const std::string FGFunction::tan_string =
"tan";
79 const std::string FGFunction::asin_string =
"asin";
80 const std::string FGFunction::acos_string =
"acos";
81 const std::string FGFunction::atan_string =
"atan";
82 const std::string FGFunction::atan2_string =
"atan2";
83 const std::string FGFunction::min_string =
"min";
84 const std::string FGFunction::max_string =
"max";
85 const std::string FGFunction::avg_string =
"avg";
86 const std::string FGFunction::fraction_string =
"fraction";
87 const std::string FGFunction::mod_string =
"mod";
88 const std::string FGFunction::random_string =
"random";
89 const std::string FGFunction::urandom_string =
"urandom";
90 const std::string FGFunction::pi_string =
"pi";
91 const std::string FGFunction::integer_string =
"integer";
92 const std::string FGFunction::rotation_alpha_local_string =
"rotation_alpha_local";
93 const std::string FGFunction::rotation_beta_local_string =
"rotation_beta_local";
94 const std::string FGFunction::rotation_gamma_local_string =
"rotation_gamma_local";
95 const std::string FGFunction::rotation_bf_to_wf_string =
"rotation_bf_to_wf";
96 const std::string FGFunction::rotation_wf_to_bf_string =
"rotation_wf_to_bf";
98 const std::string FGFunction::lessthan_string =
"lt";
99 const std::string FGFunction::lessequal_string =
"le";
100 const std::string FGFunction::greatthan_string =
"gt";
101 const std::string FGFunction::greatequal_string =
"ge";
102 const std::string FGFunction::equal_string =
"eq";
103 const std::string FGFunction::notequal_string =
"nq";
104 const std::string FGFunction::and_string =
"and";
105 const std::string FGFunction::or_string =
"or";
106 const std::string FGFunction::not_string =
"not";
107 const std::string FGFunction::ifthen_string =
"ifthen";
108 const std::string FGFunction::switch_string =
"switch";
109 const std::string FGFunction::interpolate1d_string =
"interpolate1d";
112 : PropertyManager(propMan), Prefix(prefix)
115 string operation, property_name;
117 cachedValue = -HUGE_VAL;
118 invlog2val = 1.0/log10(2.0);
124 if (operation == function_string) {
126 if (!sCopyTo.empty()) {
128 if (sCopyTo.find(
"#") != string::npos) {
129 if (is_number(Prefix)) sCopyTo = replace(sCopyTo,
"#",Prefix);
132 pCopyTo = PropertyManager->GetNode(sCopyTo);
133 if (pCopyTo == 0L) cerr <<
"Property \"" << sCopyTo <<
"\" must be previously defined in function " 137 }
else if (operation == product_string) {
139 }
else if (operation == difference_string) {
141 }
else if (operation == sum_string) {
143 }
else if (operation == quotient_string) {
145 }
else if (operation == pow_string) {
147 }
else if (operation == sqrt_string) {
149 }
else if (operation == toradians_string) {
151 }
else if (operation == todegrees_string) {
153 }
else if (operation == log2_string) {
155 }
else if (operation == ln_string) {
157 }
else if (operation == log10_string) {
159 }
else if (operation == abs_string) {
161 }
else if (operation == sign_string) {
163 }
else if (operation == sin_string) {
165 }
else if (operation == exp_string) {
167 }
else if (operation == cos_string) {
169 }
else if (operation == tan_string) {
171 }
else if (operation == asin_string) {
173 }
else if (operation == acos_string) {
175 }
else if (operation == atan_string) {
177 }
else if (operation == atan2_string) {
179 }
else if (operation == min_string) {
181 }
else if (operation == max_string) {
183 }
else if (operation == avg_string) {
185 }
else if (operation == fraction_string) {
187 }
else if (operation == integer_string) {
189 }
else if (operation == mod_string) {
191 }
else if (operation == random_string) {
193 }
else if (operation == urandom_string) {
195 }
else if (operation == pi_string) {
197 }
else if (operation == rotation_alpha_local_string) {
198 Type = eRotation_alpha_local;
199 }
else if (operation == rotation_beta_local_string) {
200 Type = eRotation_beta_local;
201 }
else if (operation == rotation_gamma_local_string) {
202 Type = eRotation_gamma_local;
203 }
else if (operation == rotation_bf_to_wf_string) {
204 Type = eRotation_bf_to_wf;
205 }
else if (operation == rotation_wf_to_bf_string) {
206 Type = eRotation_wf_to_bf;
207 }
else if (operation == lessthan_string) {
209 }
else if (operation == lessequal_string) {
211 }
else if (operation == greatthan_string) {
213 }
else if (operation == greatequal_string) {
215 }
else if (operation == equal_string) {
217 }
else if (operation == notequal_string) {
219 }
else if (operation == and_string) {
221 }
else if (operation == or_string) {
223 }
else if (operation == not_string) {
225 }
else if (operation == ifthen_string) {
227 }
else if (operation == switch_string) {
229 }
else if (operation == interpolate1d_string) {
230 Type = eInterpolate1D;
231 }
else if (operation != description_string) {
232 cerr <<
"Bad operation " << operation <<
" detected in configuration file" << endl;
236 if (!element && Type != eRandom && Type != eUrandom && Type != ePi) {
238 cerr <<
" No element was specified as an argument to the \"" << operation <<
"\" operation" << endl;
239 cerr <<
" This can happen when, for instance, a cos operation is specified and a " << endl;
240 cerr <<
" property name is given explicitly, but is not placed within a" << endl;
241 cerr <<
" <property></property> element tag pair." << endl;
247 operation = element->
GetName();
250 if (operation == property_string || operation == p_string) {
252 if (property_name.find(
"#") != string::npos) {
253 if (is_number(Prefix)) {
254 property_name = replace(property_name,
"#",Prefix);
257 if (PropertyManager->HasNode(property_name)) {
258 FGPropertyNode* newNode = PropertyManager->GetNode(property_name);
266 }
else if (operation == value_string || operation == v_string) {
268 }
else if (operation == table_string || operation == t_string) {
269 Parameters.push_back(
new FGTable(PropertyManager, element));
271 }
else if (operation == product_string ||
272 operation == difference_string ||
273 operation == sum_string ||
274 operation == quotient_string ||
275 operation == pow_string ||
276 operation == sqrt_string ||
277 operation == toradians_string ||
278 operation == todegrees_string ||
279 operation == exp_string ||
280 operation == log2_string ||
281 operation == ln_string ||
282 operation == log10_string ||
283 operation == abs_string ||
284 operation == sign_string ||
285 operation == sin_string ||
286 operation == cos_string ||
287 operation == tan_string ||
288 operation == asin_string ||
289 operation == acos_string ||
290 operation == atan_string ||
291 operation == atan2_string ||
292 operation == min_string ||
293 operation == max_string ||
294 operation == fraction_string ||
295 operation == integer_string ||
296 operation == mod_string ||
297 operation == random_string ||
298 operation == urandom_string ||
299 operation == pi_string ||
300 operation == avg_string ||
301 operation == rotation_alpha_local_string||
302 operation == rotation_beta_local_string||
303 operation == rotation_gamma_local_string||
304 operation == rotation_bf_to_wf_string||
305 operation == rotation_wf_to_bf_string ||
306 operation == lessthan_string ||
307 operation == lessequal_string ||
308 operation == greatthan_string ||
309 operation == greatequal_string ||
310 operation == equal_string ||
311 operation == notequal_string ||
312 operation == and_string ||
313 operation == or_string ||
314 operation == not_string ||
315 operation == ifthen_string ||
316 operation == switch_string ||
317 operation == interpolate1d_string)
319 Parameters.push_back(
new FGFunction(PropertyManager, element, Prefix));
320 }
else if (operation != description_string) {
321 cerr <<
"Bad operation " << operation <<
" detected in configuration file" << endl;
335 for (
unsigned int i=0; i<Parameters.size(); i++)
delete Parameters[i];
352 unsigned int FGFunction::GetBinary(
double val)
const 355 if (val < 1E-9)
return 0;
356 else if (val-1 < 1E-9)
return 1;
358 throw(
"Malformed conditional check in function definition.");
370 if (cached)
return cachedValue;
374 && Type != ePi ) temp = Parameters[0]->GetValue();
378 if (pCopyTo) pCopyTo->setDoubleValue(temp);
381 for (i=1;i<Parameters.size();i++) {
382 temp *= Parameters[i]->GetValue();
386 for (i=1;i<Parameters.size();i++) {
387 temp -= Parameters[i]->GetValue();
391 for (i=1;i<Parameters.size();i++) {
392 temp += Parameters[i]->GetValue();
396 if (Parameters[1]->
GetValue() != 0.0)
397 temp /= Parameters[1]->GetValue();
402 temp = pow(temp,Parameters[1]->
GetValue());
417 if (temp > 0.00) temp = log10(temp)*invlog2val;
418 else temp = -HUGE_VAL;
421 if (temp > 0.00) temp = log(temp);
422 else temp = -HUGE_VAL;
425 if (temp > 0.00) temp = log10(temp);
426 else temp = -HUGE_VAL;
432 temp = temp < 0 ? -1:1;
453 temp = atan2(temp, Parameters[1]->
GetValue());
456 temp = ((int)temp) % ((int) Parameters[1]->
GetValue());
459 for (i=1;i<Parameters.size();i++) {
464 for (i=1;i<Parameters.size();i++) {
469 for (i=1;i<Parameters.size();i++) {
470 temp += Parameters[i]->GetValue();
472 temp /= Parameters.size();
475 temp = modf(temp, &scratch);
478 modf(temp, &scratch);
482 temp = GaussianRandomNumber();
485 temp = -1.0 + (((double)rand()/double(RAND_MAX))*2.0);
491 temp = (temp < Parameters[1]->GetValue())?1:0;
494 temp = (temp <= Parameters[1]->GetValue())?1:0;
497 temp = (temp > Parameters[1]->GetValue())?1:0;
500 temp = (temp >= Parameters[1]->GetValue())?1:0;
503 temp = (temp == Parameters[1]->GetValue())?1:0;
506 temp = (temp != Parameters[1]->GetValue())?1:0;
510 bool flag = (GetBinary(temp) != 0u);
511 for (i=1; i<Parameters.size() && flag; i++) {
512 flag = (GetBinary(Parameters[i]->
GetValue()) != 0);
519 bool flag = (GetBinary(temp) != 0);
520 for (i=1; i<Parameters.size() && !flag; i++) {
521 flag = (GetBinary(Parameters[i]->
GetValue()) != 0);
527 temp = (GetBinary(temp) != 0) ? 0 : 1;
531 i = Parameters.size();
533 if (GetBinary(temp) == 1) {
534 temp = Parameters[1]->GetValue();
536 temp = Parameters[2]->GetValue();
539 throw(
"Malformed if/then function statement");
545 size_t n = Parameters.size()-1;
548 temp = Parameters[i+1]->GetValue();
550 throw(
string(
"The switch function index selected a value above the range of supplied values" 551 " - not enough values were supplied."));
557 size_t sz = Parameters.size();
558 if (temp <= Parameters[1]->
GetValue()) {
559 temp = Parameters[2]->GetValue();
560 }
else if (temp >= Parameters[sz-2]->
GetValue()) {
561 temp = Parameters[sz-1]->GetValue();
563 for (
unsigned int i=1; i<=sz-4; i+=2) {
564 if (temp < Parameters[i+2]->
GetValue()) {
565 double factor = (temp - Parameters[i]->GetValue()) /
566 (Parameters[i+2]->
GetValue() - Parameters[i]->GetValue());
567 double span = Parameters[i+3]->GetValue() - Parameters[i+1]->GetValue();
568 double val = factor*span;
569 temp = Parameters[i+1]->GetValue() + val;
576 case eRotation_alpha_local:
577 if (Parameters.size()==6)
580 double alpha = Parameters[0]->GetValue()*degtorad;
581 double beta = Parameters[1]->GetValue()*degtorad;
582 double gamma = Parameters[2]->GetValue()*degtorad;
583 double phi = Parameters[3]->GetValue()*degtorad;
584 double theta = Parameters[4]->GetValue()*degtorad;
585 double psi = Parameters[5]->GetValue()*degtorad;
586 double cphi2 = cos(-phi/2), ctht2 = cos(-theta/2), cpsi2 = cos(-psi/2);
587 double sphi2 = sin(-phi/2), stht2 = sin(-theta/2), spsi2 = sin(-psi/2);
588 double calpha2 = cos(-alpha/2), salpha2 = sin(-alpha/2);
589 double cbeta2 = cos(beta/2), sbeta2 = sin(beta/2);
590 double cgamma2 = cos(-gamma/2), sgamma2 = sin(-gamma/2);
592 double At = cphi2*ctht2*cpsi2 - sphi2*stht2*spsi2;
593 double Ax = cphi2*stht2*spsi2 + sphi2*ctht2*cpsi2;
594 double Ay = cphi2*stht2*cpsi2 - sphi2*ctht2*spsi2;
595 double Az = cphi2*ctht2*spsi2 + sphi2*stht2*cpsi2;
597 double Bt = calpha2*cbeta2*cgamma2 - salpha2*sbeta2*sgamma2;
598 double Bx = calpha2*cbeta2*sgamma2 + salpha2*sbeta2*cgamma2;
599 double By = calpha2*sbeta2*sgamma2 + salpha2*cbeta2*cgamma2;
600 double Bz = calpha2*sbeta2*cgamma2 - salpha2*cbeta2*sgamma2;
602 double Ct = At*Bt - Ax*Bx - Ay*By - Az*Bz;
603 double Cx = At*Bx + Ax*Bt + Ay*Bz - Az*By;
604 double Cy = At*By - Ax*Bz + Ay*Bt + Az*Bx;
605 double Cz = At*Bz + Ax*By - Ay*Bx + Az*Bt;
607 temp = -atan2(2*(Cy*Ct-Cx*Cz),(Ct*Ct+Cx*Cx-Cy*Cy-Cz*Cz));
613 case eRotation_beta_local:
614 if (Parameters.size()==6)
617 double alpha = Parameters[0]->GetValue()*degtorad;
618 double beta = Parameters[1]->GetValue()*degtorad;
619 double gamma = Parameters[2]->GetValue()*degtorad;
620 double phi = Parameters[3]->GetValue()*degtorad;
621 double theta = Parameters[4]->GetValue()*degtorad;
622 double psi = Parameters[5]->GetValue()*degtorad;
623 double cphi2 = cos(-phi/2), ctht2 = cos(-theta/2), cpsi2 = cos(-psi/2);
624 double sphi2 = sin(-phi/2), stht2 = sin(-theta/2), spsi2 = sin(-psi/2);
625 double calpha2 = cos(-alpha/2), salpha2 = sin(-alpha/2);
626 double cbeta2 = cos(beta/2), sbeta2 = sin(beta/2);
627 double cgamma2 = cos(-gamma/2), sgamma2 = sin(-gamma/2);
629 double At = cphi2*ctht2*cpsi2 - sphi2*stht2*spsi2;
630 double Ax = cphi2*stht2*spsi2 + sphi2*ctht2*cpsi2;
631 double Ay = cphi2*stht2*cpsi2 - sphi2*ctht2*spsi2;
632 double Az = cphi2*ctht2*spsi2 + sphi2*stht2*cpsi2;
634 double Bt = calpha2*cbeta2*cgamma2 - salpha2*sbeta2*sgamma2;
635 double Bx = calpha2*cbeta2*sgamma2 + salpha2*sbeta2*cgamma2;
636 double By = calpha2*sbeta2*sgamma2 + salpha2*cbeta2*cgamma2;
637 double Bz = calpha2*sbeta2*cgamma2 - salpha2*cbeta2*sgamma2;
639 double Ct = At*Bt - Ax*Bx - Ay*By - Az*Bz;
640 double Cx = At*Bx + Ax*Bt + Ay*Bz - Az*By;
641 double Cy = At*By - Ax*Bz + Ay*Bt + Az*Bx;
642 double Cz = At*Bz + Ax*By - Ay*Bx + Az*Bt;
644 temp = asin(2*(Cx*Cy+Cz*Ct));
650 case eRotation_gamma_local:
651 if (Parameters.size()==6)
654 double alpha = Parameters[0]->GetValue()*degtorad;
655 double beta = Parameters[1]->GetValue()*degtorad;
656 double gamma = Parameters[2]->GetValue()*degtorad;
657 double phi = Parameters[3]->GetValue()*degtorad;
658 double theta = Parameters[4]->GetValue()*degtorad;
659 double psi = Parameters[5]->GetValue()*degtorad;
660 double cphi2 = cos(-phi/2), ctht2 = cos(-theta/2), cpsi2 = cos(-psi/2);
661 double sphi2 = sin(-phi/2), stht2 = sin(-theta/2), spsi2 = sin(-psi/2);
662 double calpha2 = cos(-alpha/2), salpha2 = sin(-alpha/2);
663 double cbeta2 = cos(beta/2), sbeta2 = sin(beta/2);
664 double cgamma2 = cos(-gamma/2), sgamma2 = sin(-gamma/2);
666 double At = cphi2*ctht2*cpsi2 - sphi2*stht2*spsi2;
667 double Ax = cphi2*stht2*spsi2 + sphi2*ctht2*cpsi2;
668 double Ay = cphi2*stht2*cpsi2 - sphi2*ctht2*spsi2;
669 double Az = cphi2*ctht2*spsi2 + sphi2*stht2*cpsi2;
671 double Bt = calpha2*cbeta2*cgamma2 - salpha2*sbeta2*sgamma2;
672 double Bx = calpha2*cbeta2*sgamma2 + salpha2*sbeta2*cgamma2;
673 double By = calpha2*sbeta2*sgamma2 + salpha2*cbeta2*cgamma2;
674 double Bz = calpha2*sbeta2*cgamma2 - salpha2*cbeta2*sgamma2;
676 double Ct = At*Bt - Ax*Bx - Ay*By - Az*Bz;
677 double Cx = At*Bx + Ax*Bt + Ay*Bz - Az*By;
678 double Cy = At*By - Ax*Bz + Ay*Bt + Az*Bx;
679 double Cz = At*Bz + Ax*By - Ay*Bx + Az*Bt;
681 temp = -atan2(2*(Cx*Ct-Cz*Cy),(Ct*Ct-Cx*Cx+Cy*Cy-Cz*Cz));
687 case eRotation_bf_to_wf:
688 if (Parameters.size()==7)
690 double rx = Parameters[0]->GetValue();
691 double ry = Parameters[1]->GetValue();
692 double rz = Parameters[2]->GetValue();
693 double alpha = Parameters[3]->GetValue()*degtorad;
694 double beta = Parameters[4]->GetValue()*degtorad;
695 double gamma = Parameters[5]->GetValue()*degtorad;
696 double index = Parameters[6]->GetValue();
697 double calpha2 = cos(-alpha/2), salpha2 = sin(-alpha/2);
698 double cbeta2 = cos(beta/2), sbeta2 = sin(beta/2);
699 double cgamma2 = cos(-gamma/2), sgamma2 = sin(-gamma/2);
701 double qt = calpha2*cbeta2*cgamma2 - salpha2*sbeta2*sgamma2;
702 double qx = calpha2*cbeta2*sgamma2 + salpha2*sbeta2*cgamma2;
703 double qy = calpha2*sbeta2*sgamma2 + salpha2*cbeta2*cgamma2;
704 double qz = calpha2*sbeta2*cgamma2 - salpha2*cbeta2*sgamma2;
711 double vqt = -rx*qx - ry*qy - rz*qz;
712 double vqx = rx*qt + ry*qz - rz*qy;
713 double vqy = -rx*qz + ry*qt + rz*qx;
714 double vqz = rx*qy - ry*qx + rz*qt;
716 double Cx = qstart*vqx + qstarx*vqt + qstary*vqz - qstarz*vqy;
717 double Cy = qstart*vqy - qstarx*vqz + qstary*vqt + qstarz*vqx;
718 double Cz = qstart*vqz + qstarx*vqy - qstary*vqx + qstarz*vqt;
720 if (index == 1) temp = Cx;
721 else if (index ==2) temp = Cy;
727 case eRotation_wf_to_bf:
728 if (Parameters.size()==7)
730 double rx = Parameters[0]->GetValue();
731 double ry = Parameters[1]->GetValue();
732 double rz = Parameters[2]->GetValue();
733 double alpha = Parameters[3]->GetValue()*degtorad;
734 double beta = Parameters[4]->GetValue()*degtorad;
735 double gamma = Parameters[5]->GetValue()*degtorad;
736 double index = Parameters[6]->GetValue();
737 double calpha2 = cos(alpha/2), salpha2 = sin(alpha/2);
738 double cbeta2 = cos(-beta/2), sbeta2 = sin(-beta/2);
739 double cgamma2 = cos(gamma/2), sgamma2 = sin(gamma/2);
741 double qt = cgamma2*cbeta2*calpha2 + sgamma2*sbeta2*salpha2;
742 double qx = -cgamma2*sbeta2*salpha2 + sgamma2*cbeta2*calpha2;
743 double qy = cgamma2*cbeta2*salpha2 - sgamma2*sbeta2*calpha2;
744 double qz = cgamma2*sbeta2*calpha2 + sgamma2*cbeta2*salpha2;
751 double vqt = -rx*qx - ry*qy - rz*qz;
752 double vqx = rx*qt + ry*qz - rz*qy;
753 double vqy = -rx*qz + ry*qt + rz*qx;
754 double vqz = rx*qy - ry*qx + rz*qt;
756 double Cx = qstart*vqx + qstarx*vqt + qstary*vqz - qstarz*vqy;
757 double Cy = qstart*vqy - qstarx*vqz + qstary*vqt + qstarz*vqx;
758 double Cz = qstart*vqz + qstarx*vqy - qstary*vqx + qstarz*vqt;
760 if (index == 1) temp = Cx;
761 else if (index ==2) temp = Cy;
768 cerr <<
"Unknown function operation type" << endl;
779 ostringstream buffer;
781 buffer << setw(9) << setprecision(6) <<
GetValue();
787 void FGFunction::bind(
void)
789 if ( !Name.empty() ) {
794 if (is_number(Prefix)) {
795 if (Name.find(
"#") != string::npos) {
796 Name = replace(Name,
"#",Prefix);
799 cerr <<
"Malformed function name with number: " << Prefix
800 <<
" and property name: " << Name
801 <<
" but no \"#\" sign for substitution." << endl;
804 tmp = PropertyManager->
mkPropertyName(Prefix +
"/" + Name,
false);
808 if (PropertyManager->HasNode(tmp)) {
810 if (_property->isTied()) {
811 cout <<
"Property " << tmp <<
" has already been successfully bound (late)." << endl;
812 throw(
"Failed to bind the property to an existing already tied node.");
838 void FGFunction::Debug(
int from)
840 if (debug_lvl <= 0)
return;
844 if (Type == eTopLevel)
845 cout <<
" Function: " << Name << endl;
848 if (debug_lvl & 2 ) {
849 if (from == 0) cout <<
"Instantiated: FGFunction" << endl;
850 if (from == 1) cout <<
"Destroyed: FGFunction" << endl;
852 if (debug_lvl & 4 ) {
854 if (debug_lvl & 8 ) {
856 if (debug_lvl & 16) {
858 if (debug_lvl & 64) {
860 cout << IdSrc << endl;
861 cout << IdHdr << endl;
virtual ~FGFunction()
Destructor.
std::string GetValueAsString(void) const
The value that the function evaluates to, as a string.
std::string GetAttributeValue(const std::string &key)
Retrieves an attribute.
std::string mkPropertyName(std::string name, bool lowercase)
Property-ify a name replaces spaces with '-' and, optionally, makes name all lower case...
Represents a property value which can use late binding.
Class wrapper for property handling.
static char reset[5]
resets text properties
double GetValue(void) const
Retrieves the value of the function object.
void cacheValue(bool shouldCache)
Specifies whether to cache the value of the function, so it is calculated only once per frame...
static char fgred[6]
red text
void Tie(const std::string &name, bool *pointer, bool useDefault=true)
Tie a property to an external bool variable.
double GetDataAsNumber(void)
Converts the element data to a number.
const std::string & GetName(void) const
Retrieves the element name.
std::string GetDataLine(unsigned int i=0)
Gets a line of data belonging to an element.
static char highint[5]
highlights text
Element * GetElement(unsigned int el=0)
Returns a pointer to the element requested by index.
FGFunction(FGPropertyManager *PropertyManager, Element *element, const std::string &prefix="")
Constructor.
Element * GetNextElement(void)
Returns a pointer to the next element in the list.