Always set useDefault to false when calling SGPropertyNode::tie()
Setting useDefault to true is equivalent to using unitialized variables we are getting whatever is currently in the memory whether it is relevant or not.
This commit is contained in:
parent
12996087de
commit
d3a11d72bb
12 changed files with 108 additions and 164 deletions
|
@ -155,17 +155,17 @@ FGFDMExec::FGFDMExec(FGPropertyManager* root, unsigned int* fdmctr)
|
|||
|
||||
Constructing = true;
|
||||
typedef int (FGFDMExec::*iPMF)(void) const;
|
||||
instance->Tie("simulation/do_simple_trim", this, (iPMF)0, &FGFDMExec::DoTrim, false);
|
||||
instance->Tie("simulation/reset", this, (iPMF)0, &FGFDMExec::ResetToInitialConditions, false);
|
||||
instance->Tie("simulation/do_simple_trim", this, (iPMF)0, &FGFDMExec::DoTrim);
|
||||
instance->Tie("simulation/reset", this, (iPMF)0, &FGFDMExec::ResetToInitialConditions);
|
||||
instance->Tie("simulation/disperse", this, &FGFDMExec::GetDisperse);
|
||||
instance->Tie("simulation/randomseed", this, (iPMF)&FGFDMExec::SRand, &FGFDMExec::SRand, false);
|
||||
instance->Tie("simulation/randomseed", this, (iPMF)&FGFDMExec::SRand, &FGFDMExec::SRand);
|
||||
instance->Tie("simulation/terminate", (int *)&Terminate);
|
||||
instance->Tie("simulation/pause", (int *)&holding);
|
||||
instance->Tie("simulation/sim-time-sec", this, &FGFDMExec::GetSimTime);
|
||||
instance->Tie("simulation/dt", this, &FGFDMExec::GetDeltaT);
|
||||
instance->Tie("simulation/jsbsim-debug", this, &FGFDMExec::GetDebugLevel, &FGFDMExec::SetDebugLevel);
|
||||
instance->Tie("simulation/frame", (int *)&Frame, false);
|
||||
instance->Tie("simulation/trim-completed", (int *)&trim_completed, false);
|
||||
instance->Tie("simulation/frame", (int *)&Frame);
|
||||
instance->Tie("simulation/trim-completed", (int *)&trim_completed);
|
||||
instance->Tie("forces/hold-down", this, &FGFDMExec::GetHoldDown, &FGFDMExec::SetHoldDown);
|
||||
|
||||
Constructing = false;
|
||||
|
|
|
@ -1450,80 +1450,61 @@ void FGInitialCondition::bind(FGPropertyManager* PropertyManager)
|
|||
{
|
||||
PropertyManager->Tie("ic/vc-kts", this,
|
||||
&FGInitialCondition::GetVcalibratedKtsIC,
|
||||
&FGInitialCondition::SetVcalibratedKtsIC,
|
||||
true);
|
||||
&FGInitialCondition::SetVcalibratedKtsIC);
|
||||
PropertyManager->Tie("ic/ve-kts", this,
|
||||
&FGInitialCondition::GetVequivalentKtsIC,
|
||||
&FGInitialCondition::SetVequivalentKtsIC,
|
||||
true);
|
||||
&FGInitialCondition::SetVequivalentKtsIC);
|
||||
PropertyManager->Tie("ic/vg-kts", this,
|
||||
&FGInitialCondition::GetVgroundKtsIC,
|
||||
&FGInitialCondition::SetVgroundKtsIC,
|
||||
true);
|
||||
&FGInitialCondition::SetVgroundKtsIC);
|
||||
PropertyManager->Tie("ic/vt-kts", this,
|
||||
&FGInitialCondition::GetVtrueKtsIC,
|
||||
&FGInitialCondition::SetVtrueKtsIC,
|
||||
true);
|
||||
&FGInitialCondition::SetVtrueKtsIC);
|
||||
PropertyManager->Tie("ic/mach", this,
|
||||
&FGInitialCondition::GetMachIC,
|
||||
&FGInitialCondition::SetMachIC,
|
||||
true);
|
||||
&FGInitialCondition::SetMachIC);
|
||||
PropertyManager->Tie("ic/roc-fpm", this,
|
||||
&FGInitialCondition::GetClimbRateFpmIC,
|
||||
&FGInitialCondition::SetClimbRateFpmIC,
|
||||
true);
|
||||
&FGInitialCondition::SetClimbRateFpmIC);
|
||||
PropertyManager->Tie("ic/gamma-deg", this,
|
||||
&FGInitialCondition::GetFlightPathAngleDegIC,
|
||||
&FGInitialCondition::SetFlightPathAngleDegIC,
|
||||
true);
|
||||
&FGInitialCondition::SetFlightPathAngleDegIC);
|
||||
PropertyManager->Tie("ic/alpha-deg", this,
|
||||
&FGInitialCondition::GetAlphaDegIC,
|
||||
&FGInitialCondition::SetAlphaDegIC,
|
||||
true);
|
||||
&FGInitialCondition::SetAlphaDegIC);
|
||||
PropertyManager->Tie("ic/beta-deg", this,
|
||||
&FGInitialCondition::GetBetaDegIC,
|
||||
&FGInitialCondition::SetBetaDegIC,
|
||||
true);
|
||||
&FGInitialCondition::SetBetaDegIC);
|
||||
PropertyManager->Tie("ic/theta-deg", this,
|
||||
&FGInitialCondition::GetThetaDegIC,
|
||||
&FGInitialCondition::SetThetaDegIC,
|
||||
true);
|
||||
&FGInitialCondition::SetThetaDegIC);
|
||||
PropertyManager->Tie("ic/phi-deg", this,
|
||||
&FGInitialCondition::GetPhiDegIC,
|
||||
&FGInitialCondition::SetPhiDegIC,
|
||||
true);
|
||||
&FGInitialCondition::SetPhiDegIC);
|
||||
PropertyManager->Tie("ic/psi-true-deg", this,
|
||||
&FGInitialCondition::GetPsiDegIC,
|
||||
&FGInitialCondition::SetPsiDegIC,
|
||||
true);
|
||||
&FGInitialCondition::SetPsiDegIC);
|
||||
PropertyManager->Tie("ic/lat-gc-deg", this,
|
||||
&FGInitialCondition::GetLatitudeDegIC,
|
||||
&FGInitialCondition::SetLatitudeDegIC,
|
||||
true);
|
||||
&FGInitialCondition::SetLatitudeDegIC);
|
||||
PropertyManager->Tie("ic/long-gc-deg", this,
|
||||
&FGInitialCondition::GetLongitudeDegIC,
|
||||
&FGInitialCondition::SetLongitudeDegIC,
|
||||
true);
|
||||
&FGInitialCondition::SetLongitudeDegIC);
|
||||
PropertyManager->Tie("ic/h-sl-ft", this,
|
||||
&FGInitialCondition::GetAltitudeASLFtIC,
|
||||
&FGInitialCondition::SetAltitudeASLFtIC,
|
||||
true);
|
||||
&FGInitialCondition::SetAltitudeASLFtIC);
|
||||
PropertyManager->Tie("ic/h-agl-ft", this,
|
||||
&FGInitialCondition::GetAltitudeAGLFtIC,
|
||||
&FGInitialCondition::SetAltitudeAGLFtIC,
|
||||
true);
|
||||
&FGInitialCondition::SetAltitudeAGLFtIC);
|
||||
PropertyManager->Tie("ic/terrain-elevation-ft", this,
|
||||
&FGInitialCondition::GetTerrainElevationFtIC,
|
||||
&FGInitialCondition::SetTerrainElevationFtIC,
|
||||
true);
|
||||
&FGInitialCondition::SetTerrainElevationFtIC);
|
||||
PropertyManager->Tie("ic/vg-fps", this,
|
||||
&FGInitialCondition::GetVgroundFpsIC,
|
||||
&FGInitialCondition::SetVgroundFpsIC,
|
||||
true);
|
||||
&FGInitialCondition::SetVgroundFpsIC);
|
||||
PropertyManager->Tie("ic/vt-fps", this,
|
||||
&FGInitialCondition::GetVtrueFpsIC,
|
||||
&FGInitialCondition::SetVtrueFpsIC,
|
||||
true);
|
||||
&FGInitialCondition::SetVtrueFpsIC);
|
||||
PropertyManager->Tie("ic/vw-bx-fps", this,
|
||||
&FGInitialCondition::GetWindUFpsIC);
|
||||
PropertyManager->Tie("ic/vw-by-fps", this,
|
||||
|
@ -1540,96 +1521,74 @@ void FGInitialCondition::bind(FGPropertyManager* PropertyManager)
|
|||
&FGInitialCondition::GetWindFpsIC);
|
||||
PropertyManager->Tie("ic/vw-dir-deg", this,
|
||||
&FGInitialCondition::GetWindDirDegIC,
|
||||
&FGInitialCondition::SetWindDirDegIC,
|
||||
true);
|
||||
&FGInitialCondition::SetWindDirDegIC);
|
||||
|
||||
PropertyManager->Tie("ic/roc-fps", this,
|
||||
&FGInitialCondition::GetClimbRateFpsIC,
|
||||
&FGInitialCondition::SetClimbRateFpsIC,
|
||||
true);
|
||||
&FGInitialCondition::SetClimbRateFpsIC);
|
||||
PropertyManager->Tie("ic/u-fps", this,
|
||||
&FGInitialCondition::GetUBodyFpsIC,
|
||||
&FGInitialCondition::SetUBodyFpsIC,
|
||||
true);
|
||||
&FGInitialCondition::SetUBodyFpsIC);
|
||||
PropertyManager->Tie("ic/v-fps", this,
|
||||
&FGInitialCondition::GetVBodyFpsIC,
|
||||
&FGInitialCondition::SetVBodyFpsIC,
|
||||
true);
|
||||
&FGInitialCondition::SetVBodyFpsIC);
|
||||
PropertyManager->Tie("ic/w-fps", this,
|
||||
&FGInitialCondition::GetWBodyFpsIC,
|
||||
&FGInitialCondition::SetWBodyFpsIC,
|
||||
true);
|
||||
&FGInitialCondition::SetWBodyFpsIC);
|
||||
PropertyManager->Tie("ic/vn-fps", this,
|
||||
&FGInitialCondition::GetVNorthFpsIC,
|
||||
&FGInitialCondition::SetVNorthFpsIC,
|
||||
true);
|
||||
&FGInitialCondition::SetVNorthFpsIC);
|
||||
PropertyManager->Tie("ic/ve-fps", this,
|
||||
&FGInitialCondition::GetVEastFpsIC,
|
||||
&FGInitialCondition::SetVEastFpsIC,
|
||||
true);
|
||||
&FGInitialCondition::SetVEastFpsIC);
|
||||
PropertyManager->Tie("ic/vd-fps", this,
|
||||
&FGInitialCondition::GetVDownFpsIC,
|
||||
&FGInitialCondition::SetVDownFpsIC,
|
||||
true);
|
||||
&FGInitialCondition::SetVDownFpsIC);
|
||||
PropertyManager->Tie("ic/gamma-rad", this,
|
||||
&FGInitialCondition::GetFlightPathAngleRadIC,
|
||||
&FGInitialCondition::SetFlightPathAngleRadIC,
|
||||
true);
|
||||
&FGInitialCondition::SetFlightPathAngleRadIC);
|
||||
PropertyManager->Tie("ic/alpha-rad", this,
|
||||
&FGInitialCondition::GetAlphaRadIC,
|
||||
&FGInitialCondition::SetAlphaRadIC,
|
||||
true);
|
||||
&FGInitialCondition::SetAlphaRadIC);
|
||||
PropertyManager->Tie("ic/theta-rad", this,
|
||||
&FGInitialCondition::GetThetaRadIC,
|
||||
&FGInitialCondition::SetThetaRadIC,
|
||||
true);
|
||||
&FGInitialCondition::SetThetaRadIC);
|
||||
PropertyManager->Tie("ic/beta-rad", this,
|
||||
&FGInitialCondition::GetBetaRadIC,
|
||||
&FGInitialCondition::SetBetaRadIC,
|
||||
true);
|
||||
&FGInitialCondition::SetBetaRadIC);
|
||||
PropertyManager->Tie("ic/phi-rad", this,
|
||||
&FGInitialCondition::GetPhiRadIC,
|
||||
&FGInitialCondition::SetPhiRadIC,
|
||||
true);
|
||||
&FGInitialCondition::SetPhiRadIC);
|
||||
PropertyManager->Tie("ic/psi-true-rad", this,
|
||||
&FGInitialCondition::GetPsiRadIC,
|
||||
&FGInitialCondition::SetPsiRadIC,
|
||||
true);
|
||||
&FGInitialCondition::SetPsiRadIC);
|
||||
PropertyManager->Tie("ic/lat-gc-rad", this,
|
||||
&FGInitialCondition::GetLatitudeRadIC,
|
||||
&FGInitialCondition::SetLatitudeRadIC,
|
||||
true);
|
||||
&FGInitialCondition::SetLatitudeRadIC);
|
||||
PropertyManager->Tie("ic/long-gc-rad", this,
|
||||
&FGInitialCondition::GetLongitudeRadIC,
|
||||
&FGInitialCondition::SetLongitudeRadIC,
|
||||
true);
|
||||
&FGInitialCondition::SetLongitudeRadIC);
|
||||
PropertyManager->Tie("ic/p-rad_sec", this,
|
||||
&FGInitialCondition::GetPRadpsIC,
|
||||
&FGInitialCondition::SetPRadpsIC,
|
||||
true);
|
||||
&FGInitialCondition::SetPRadpsIC);
|
||||
PropertyManager->Tie("ic/q-rad_sec", this,
|
||||
&FGInitialCondition::GetQRadpsIC,
|
||||
&FGInitialCondition::SetQRadpsIC,
|
||||
true);
|
||||
&FGInitialCondition::SetQRadpsIC);
|
||||
PropertyManager->Tie("ic/r-rad_sec", this,
|
||||
&FGInitialCondition::GetRRadpsIC,
|
||||
&FGInitialCondition::SetRRadpsIC,
|
||||
true);
|
||||
&FGInitialCondition::SetRRadpsIC);
|
||||
PropertyManager->Tie("ic/lat-geod-rad", this,
|
||||
&FGInitialCondition::GetGeodLatitudeRadIC,
|
||||
&FGInitialCondition::SetGeodLatitudeRadIC,
|
||||
true);
|
||||
&FGInitialCondition::SetGeodLatitudeRadIC);
|
||||
PropertyManager->Tie("ic/lat-geod-deg", this,
|
||||
&FGInitialCondition::GetGeodLatitudeDegIC,
|
||||
&FGInitialCondition::SetGeodLatitudeDegIC,
|
||||
true);
|
||||
&FGInitialCondition::SetGeodLatitudeDegIC);
|
||||
PropertyManager->Tie("ic/geod-alt-ft", &position,
|
||||
&FGLocation::GetGeodAltitude);
|
||||
|
||||
PropertyManager->Tie("ic/targetNlf", this,
|
||||
&FGInitialCondition::GetTargetNlfIC,
|
||||
&FGInitialCondition::SetTargetNlfIC,
|
||||
true);
|
||||
&FGInitialCondition::SetTargetNlfIC);
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
|
|
@ -92,7 +92,7 @@ void FGOutputType::SetIdx(unsigned int idx)
|
|||
{
|
||||
string outputProp = CreateIndexedPropertyName("simulation/output", idx);
|
||||
|
||||
PropertyManager->Tie(outputProp + "/log_rate_hz", this, &FGOutputType::GetRateHz, &FGOutputType::SetRateHz, false);
|
||||
PropertyManager->Tie(outputProp + "/log_rate_hz", this, &FGOutputType::GetRateHz, &FGOutputType::SetRateHz);
|
||||
PropertyManager->Tie(outputProp + "/enabled", &enabled);
|
||||
OutputIdx = idx;
|
||||
}
|
||||
|
|
|
@ -327,7 +327,7 @@ void FGPropertyManager::Untie (const string &name)
|
|||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
void FGPropertyManager::Tie (const string &name, bool *pointer, bool useDefault)
|
||||
void FGPropertyManager::Tie (const string &name, bool *pointer)
|
||||
{
|
||||
SGPropertyNode* property = root->getNode(name.c_str(), true);
|
||||
if (!property) {
|
||||
|
@ -335,7 +335,7 @@ void FGPropertyManager::Tie (const string &name, bool *pointer, bool useDefault)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!property->tie(SGRawValuePointer<bool>(pointer), useDefault))
|
||||
if (!property->tie(SGRawValuePointer<bool>(pointer), false))
|
||||
cerr << "Failed to tie property " << name << " to a pointer" << endl;
|
||||
else {
|
||||
tied_properties.push_back(property);
|
||||
|
@ -345,8 +345,7 @@ void FGPropertyManager::Tie (const string &name, bool *pointer, bool useDefault)
|
|||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
void FGPropertyManager::Tie (const string &name, int *pointer,
|
||||
bool useDefault )
|
||||
void FGPropertyManager::Tie (const string &name, int *pointer)
|
||||
{
|
||||
SGPropertyNode* property = root->getNode(name.c_str(), true);
|
||||
if (!property) {
|
||||
|
@ -354,7 +353,7 @@ void FGPropertyManager::Tie (const string &name, int *pointer,
|
|||
return;
|
||||
}
|
||||
|
||||
if (!property->tie(SGRawValuePointer<int>(pointer), useDefault))
|
||||
if (!property->tie(SGRawValuePointer<int>(pointer), false))
|
||||
cerr << "Failed to tie property " << name << " to a pointer" << endl;
|
||||
else {
|
||||
tied_properties.push_back(property);
|
||||
|
@ -364,8 +363,7 @@ void FGPropertyManager::Tie (const string &name, int *pointer,
|
|||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
void FGPropertyManager::Tie (const string &name, long *pointer,
|
||||
bool useDefault )
|
||||
void FGPropertyManager::Tie (const string &name, long *pointer)
|
||||
{
|
||||
SGPropertyNode* property = root->getNode(name.c_str(), true);
|
||||
if (!property) {
|
||||
|
@ -373,7 +371,7 @@ void FGPropertyManager::Tie (const string &name, long *pointer,
|
|||
return;
|
||||
}
|
||||
|
||||
if (!property->tie(SGRawValuePointer<long>(pointer), useDefault))
|
||||
if (!property->tie(SGRawValuePointer<long>(pointer), false))
|
||||
cerr << "Failed to tie property " << name << " to a pointer" << endl;
|
||||
else {
|
||||
tied_properties.push_back(property);
|
||||
|
@ -383,8 +381,7 @@ void FGPropertyManager::Tie (const string &name, long *pointer,
|
|||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
void FGPropertyManager::Tie (const string &name, float *pointer,
|
||||
bool useDefault )
|
||||
void FGPropertyManager::Tie (const string &name, float *pointer)
|
||||
{
|
||||
SGPropertyNode* property = root->getNode(name.c_str(), true);
|
||||
if (!property) {
|
||||
|
@ -392,7 +389,7 @@ void FGPropertyManager::Tie (const string &name, float *pointer,
|
|||
return;
|
||||
}
|
||||
|
||||
if (!property->tie(SGRawValuePointer<float>(pointer), useDefault))
|
||||
if (!property->tie(SGRawValuePointer<float>(pointer), false))
|
||||
cerr << "Failed to tie property " << name << " to a pointer" << endl;
|
||||
else {
|
||||
tied_properties.push_back(property);
|
||||
|
@ -402,7 +399,7 @@ void FGPropertyManager::Tie (const string &name, float *pointer,
|
|||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
void FGPropertyManager::Tie (const string &name, double *pointer, bool useDefault)
|
||||
void FGPropertyManager::Tie (const string &name, double *pointer)
|
||||
{
|
||||
SGPropertyNode* property = root->getNode(name.c_str(), true);
|
||||
if (!property) {
|
||||
|
@ -410,7 +407,7 @@ void FGPropertyManager::Tie (const string &name, double *pointer, bool useDefaul
|
|||
return;
|
||||
}
|
||||
|
||||
if (!property->tie(SGRawValuePointer<double>(pointer), useDefault))
|
||||
if (!property->tie(SGRawValuePointer<double>(pointer), false))
|
||||
cerr << "Failed to tie property " << name << " to a pointer" << endl;
|
||||
else {
|
||||
tied_properties.push_back(property);
|
||||
|
|
|
@ -439,7 +439,7 @@ class FGPropertyManager
|
|||
* be modified; defaults to true.
|
||||
*/
|
||||
void
|
||||
Tie (const std::string &name, bool *pointer, bool useDefault = true);
|
||||
Tie (const std::string &name, bool *pointer);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -455,7 +455,7 @@ class FGPropertyManager
|
|||
* be modified; defaults to true.
|
||||
*/
|
||||
void
|
||||
Tie (const std::string &name, int *pointer, bool useDefault = true);
|
||||
Tie (const std::string &name, int *pointer);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -471,7 +471,7 @@ class FGPropertyManager
|
|||
* be modified; defaults to true.
|
||||
*/
|
||||
void
|
||||
Tie (const std::string &name, long *pointer, bool useDefault = true);
|
||||
Tie (const std::string &name, long *pointer);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -487,7 +487,7 @@ class FGPropertyManager
|
|||
* be modified; defaults to true.
|
||||
*/
|
||||
void
|
||||
Tie (const std::string &name, float *pointer, bool useDefault = true);
|
||||
Tie (const std::string &name, float *pointer);
|
||||
|
||||
/**
|
||||
* Tie a property to an external double variable.
|
||||
|
@ -502,7 +502,7 @@ class FGPropertyManager
|
|||
* be modified; defaults to true.
|
||||
*/
|
||||
void
|
||||
Tie (const std::string &name, double *pointer, bool useDefault = true);
|
||||
Tie (const std::string &name, double *pointer);
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
|
@ -540,13 +540,10 @@ class FGPropertyManager
|
|||
* @param name The property name to tie (full path).
|
||||
* @param getter The getter function, or 0 if the value is unreadable.
|
||||
* @param setter The setter function, or 0 if the value is unmodifiable.
|
||||
* @param useDefault true if the setter should be invoked with any existing
|
||||
* property value should be; false if the old value should be
|
||||
* discarded; defaults to true.
|
||||
*/
|
||||
|
||||
template <class V> inline void
|
||||
Tie (const std::string &name, V (*getter)(), void (*setter)(V) = 0, bool useDefault = true)
|
||||
Tie (const std::string &name, V (*getter)(), void (*setter)(V) = nullptr)
|
||||
{
|
||||
SGPropertyNode* property = root->getNode(name.c_str(), true);
|
||||
if (!property) {
|
||||
|
@ -554,7 +551,7 @@ class FGPropertyManager
|
|||
return;
|
||||
}
|
||||
|
||||
if (!property->tie(SGRawValueFunctions<V>(getter, setter), useDefault))
|
||||
if (!property->tie(SGRawValueFunctions<V>(getter, setter), false))
|
||||
std::cerr << "Failed to tie property " << name << " to functions" << std::endl;
|
||||
else {
|
||||
if (setter == 0) property->setAttribute(SGPropertyNode::WRITE, false);
|
||||
|
@ -579,12 +576,9 @@ class FGPropertyManager
|
|||
* setter functions.
|
||||
* @param getter The getter function, or 0 if the value is unreadable.
|
||||
* @param setter The setter function, or 0 if the value is unmodifiable.
|
||||
* @param useDefault true if the setter should be invoked with any existing
|
||||
* property value should there be one; false if the old value should be
|
||||
* discarded; defaults to true.
|
||||
*/
|
||||
template <class V> inline void Tie (const std::string &name, int index, V (*getter)(int),
|
||||
void (*setter)(int, V) = 0, bool useDefault = true)
|
||||
void (*setter)(int, V) = nullptr)
|
||||
{
|
||||
SGPropertyNode* property = root->getNode(name.c_str(), true);
|
||||
if (!property) {
|
||||
|
@ -592,7 +586,7 @@ class FGPropertyManager
|
|||
return;
|
||||
}
|
||||
|
||||
if (!property->tie(SGRawValueFunctionsIndexed<V>(index, getter, setter), useDefault))
|
||||
if (!property->tie(SGRawValueFunctionsIndexed<V>(index, getter, setter), false))
|
||||
std::cerr << "Failed to tie property " << name << " to indexed functions" << std::endl;
|
||||
else {
|
||||
if (setter == 0) property->setAttribute(SGPropertyNode::WRITE, false);
|
||||
|
@ -618,13 +612,10 @@ class FGPropertyManager
|
|||
* unreadable.
|
||||
* @param setter The object's setter method, or 0 if the value is
|
||||
* unmodifiable.
|
||||
* @param useDefault true if the setter should be invoked with any existing
|
||||
* property value should there be one; false if the old value should be
|
||||
* discarded; defaults to true.
|
||||
*/
|
||||
template <class T, class V> inline void
|
||||
Tie (const std::string &name, T * obj, V (T::*getter)() const,
|
||||
void (T::*setter)(V) = 0, bool useDefault = true)
|
||||
void (T::*setter)(V) = nullptr)
|
||||
{
|
||||
SGPropertyNode* property = root->getNode(name.c_str(), true);
|
||||
if (!property) {
|
||||
|
@ -632,7 +623,7 @@ class FGPropertyManager
|
|||
return;
|
||||
}
|
||||
|
||||
if (!property->tie(SGRawValueMethods<T,V>(*obj, getter, setter), useDefault))
|
||||
if (!property->tie(SGRawValueMethods<T,V>(*obj, getter, setter), false))
|
||||
std::cerr << "Failed to tie property " << name << " to object methods" << std::endl;
|
||||
else {
|
||||
if (setter == 0) property->setAttribute(SGPropertyNode::WRITE, false);
|
||||
|
@ -657,13 +648,10 @@ class FGPropertyManager
|
|||
* setter methods.
|
||||
* @param getter The getter method, or 0 if the value is unreadable.
|
||||
* @param setter The setter method, or 0 if the value is unmodifiable.
|
||||
* @param useDefault true if the setter should be invoked with any existing
|
||||
* property value should be; false if the old value should be
|
||||
* discarded; defaults to true.
|
||||
*/
|
||||
template <class T, class V> inline void
|
||||
Tie (const std::string &name, T * obj, int index, V (T::*getter)(int) const,
|
||||
void (T::*setter)(int, V) = 0, bool useDefault = true)
|
||||
void (T::*setter)(int, V) = nullptr)
|
||||
{
|
||||
SGPropertyNode* property = root->getNode(name.c_str(), true);
|
||||
if (!property) {
|
||||
|
@ -671,7 +659,7 @@ class FGPropertyManager
|
|||
return;
|
||||
}
|
||||
|
||||
if (!property->tie(SGRawValueMethodsIndexed<T,V>(*obj, index, getter, setter), useDefault))
|
||||
if (!property->tie(SGRawValueMethodsIndexed<T,V>(*obj, index, getter, setter), false))
|
||||
std::cerr << "Failed to tie property " << name << " to indexed object methods" << std::endl;
|
||||
else {
|
||||
if (setter == 0) property->setAttribute(SGPropertyNode::WRITE, false);
|
||||
|
@ -679,7 +667,7 @@ class FGPropertyManager
|
|||
tied_properties.push_back(property);
|
||||
if (FGJSBBase::debug_lvl & 0x20) std::cout << name << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class T> simgear::PropertyObject<T>
|
||||
CreatePropertyObject(const std::string &path)
|
||||
|
|
|
@ -585,8 +585,8 @@ void FGAerodynamics::bind(void)
|
|||
PropertyManager->Tie("forces/lod-norm", this, &FGAerodynamics::GetLoD);
|
||||
PropertyManager->Tie("aero/cl-squared", this, &FGAerodynamics::GetClSquared);
|
||||
PropertyManager->Tie("aero/qbar-area", &qbar_area);
|
||||
PropertyManager->Tie("aero/alpha-max-rad", this, &FGAerodynamics::GetAlphaCLMax, &FGAerodynamics::SetAlphaCLMax, true);
|
||||
PropertyManager->Tie("aero/alpha-min-rad", this, &FGAerodynamics::GetAlphaCLMin, &FGAerodynamics::SetAlphaCLMin, true);
|
||||
PropertyManager->Tie("aero/alpha-max-rad", this, &FGAerodynamics::GetAlphaCLMax, &FGAerodynamics::SetAlphaCLMax);
|
||||
PropertyManager->Tie("aero/alpha-min-rad", this, &FGAerodynamics::GetAlphaCLMin, &FGAerodynamics::SetAlphaCLMin);
|
||||
PropertyManager->Tie("aero/bi2vel", this, &FGAerodynamics::GetBI2Vel);
|
||||
PropertyManager->Tie("aero/ci2vel", this, &FGAerodynamics::GetCI2Vel);
|
||||
PropertyManager->Tie("aero/alpha-wing-rad", this, &FGAerodynamics::GetAlphaW);
|
||||
|
|
|
@ -244,17 +244,17 @@ void FGBuoyantForces::bind(void)
|
|||
typedef double (FGBuoyantForces::*PGF)(int) const;
|
||||
typedef void (FGBuoyantForces::*PSF)(int, double);
|
||||
PropertyManager->Tie("moments/l-buoyancy-lbsft", this, eL,
|
||||
(PGF)&FGBuoyantForces::GetMoments, (PSF)0, false);
|
||||
(PGF)&FGBuoyantForces::GetMoments, (PSF)nullptr);
|
||||
PropertyManager->Tie("moments/m-buoyancy-lbsft", this, eM,
|
||||
(PGF)&FGBuoyantForces::GetMoments, (PSF)0, false);
|
||||
(PGF)&FGBuoyantForces::GetMoments, (PSF)nullptr);
|
||||
PropertyManager->Tie("moments/n-buoyancy-lbsft", this, eN,
|
||||
(PGF)&FGBuoyantForces::GetMoments, (PSF)0, false);
|
||||
(PGF)&FGBuoyantForces::GetMoments, (PSF)nullptr);
|
||||
PropertyManager->Tie("forces/fbx-buoyancy-lbs", this, eX,
|
||||
(PGF)&FGBuoyantForces::GetForces, (PSF)0, false);
|
||||
(PGF)&FGBuoyantForces::GetForces, (PSF)nullptr);
|
||||
PropertyManager->Tie("forces/fby-buoyancy-lbs", this, eY,
|
||||
(PGF)&FGBuoyantForces::GetForces, (PSF)0, false);
|
||||
(PGF)&FGBuoyantForces::GetForces, (PSF)nullptr);
|
||||
PropertyManager->Tie("forces/fbz-buoyancy-lbs", this, eZ,
|
||||
(PGF)&FGBuoyantForces::GetForces, (PSF)0, false);
|
||||
(PGF)&FGBuoyantForces::GetForces, (PSF)nullptr);
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
|
|
@ -194,20 +194,20 @@ FGGasCell::FGGasCell(FGFDMExec* exec, Element* el, unsigned int num,
|
|||
base_property_name = CreateIndexedPropertyName("buoyant_forces/gas-cell", CellNum);
|
||||
|
||||
property_name = base_property_name + "/max_volume-ft3";
|
||||
PropertyManager->Tie( property_name.c_str(), &MaxVolume, false );
|
||||
PropertyManager->GetNode()->SetWritable( property_name, false );
|
||||
PropertyManager->Tie( property_name.c_str(), &MaxVolume);
|
||||
PropertyManager->GetNode()->SetWritable( property_name);
|
||||
property_name = base_property_name + "/temp-R";
|
||||
PropertyManager->Tie( property_name.c_str(), &Temperature, false );
|
||||
PropertyManager->Tie( property_name.c_str(), &Temperature);
|
||||
property_name = base_property_name + "/pressure-psf";
|
||||
PropertyManager->Tie( property_name.c_str(), &Pressure, false );
|
||||
PropertyManager->Tie( property_name.c_str(), &Pressure);
|
||||
property_name = base_property_name + "/volume-ft3";
|
||||
PropertyManager->Tie( property_name.c_str(), &Volume, false );
|
||||
PropertyManager->Tie( property_name.c_str(), &Volume);
|
||||
property_name = base_property_name + "/buoyancy-lbs";
|
||||
PropertyManager->Tie( property_name.c_str(), &Buoyancy, false );
|
||||
PropertyManager->Tie( property_name.c_str(), &Buoyancy);
|
||||
property_name = base_property_name + "/contents-mol";
|
||||
PropertyManager->Tie( property_name.c_str(), &Contents, false );
|
||||
PropertyManager->Tie( property_name.c_str(), &Contents);
|
||||
property_name = base_property_name + "/valve_open";
|
||||
PropertyManager->Tie( property_name.c_str(), &ValveOpen, false );
|
||||
PropertyManager->Tie( property_name.c_str(), &ValveOpen);
|
||||
|
||||
Debug(0);
|
||||
|
||||
|
@ -622,23 +622,23 @@ FGBallonet::FGBallonet(FGFDMExec* exec, Element* el, unsigned int num,
|
|||
base_property_name = CreateIndexedPropertyName(base_property_name + "/ballonet", CellNum);
|
||||
|
||||
property_name = base_property_name + "/max_volume-ft3";
|
||||
PropertyManager->Tie( property_name, &MaxVolume, false );
|
||||
PropertyManager->GetNode()->SetWritable( property_name, false );
|
||||
PropertyManager->Tie( property_name, &MaxVolume);
|
||||
PropertyManager->GetNode()->SetWritable( property_name);
|
||||
|
||||
property_name = base_property_name + "/temp-R";
|
||||
PropertyManager->Tie( property_name, &Temperature, false );
|
||||
PropertyManager->Tie( property_name, &Temperature);
|
||||
|
||||
property_name = base_property_name + "/pressure-psf";
|
||||
PropertyManager->Tie( property_name, &Pressure, false );
|
||||
PropertyManager->Tie( property_name, &Pressure);
|
||||
|
||||
property_name = base_property_name + "/volume-ft3";
|
||||
PropertyManager->Tie( property_name, &Volume, false );
|
||||
PropertyManager->Tie( property_name, &Volume);
|
||||
|
||||
property_name = base_property_name + "/contents-mol";
|
||||
PropertyManager->Tie( property_name, &Contents, false );
|
||||
PropertyManager->Tie( property_name, &Contents);
|
||||
|
||||
property_name = base_property_name + "/valve_open";
|
||||
PropertyManager->Tie( property_name, &ValveOpen, false );
|
||||
PropertyManager->Tie( property_name, &ValveOpen);
|
||||
|
||||
Debug(0);
|
||||
|
||||
|
|
|
@ -418,7 +418,7 @@ void FGMassBalance::bind(void)
|
|||
&FGMassBalance::GetIyz);
|
||||
typedef int (FGMassBalance::*iOPV)() const;
|
||||
PropertyManager->Tie("inertia/print-mass-properties", this, (iOPV)0,
|
||||
&FGMassBalance::GetMassPropertiesReport, false);
|
||||
&FGMassBalance::GetMassPropertiesReport);
|
||||
}
|
||||
|
||||
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
|
|
@ -60,7 +60,7 @@ FGOutput::FGOutput(FGFDMExec* fdmex) : FGModel(fdmex)
|
|||
Name = "FGOutput";
|
||||
enabled = true;
|
||||
|
||||
PropertyManager->Tie("simulation/force-output", this, (iOPV)0, &FGOutput::ForceOutput, false);
|
||||
PropertyManager->Tie("simulation/force-output", this, (iOPV)0, &FGOutput::ForceOutput);
|
||||
|
||||
Debug(0);
|
||||
}
|
||||
|
|
|
@ -792,22 +792,22 @@ void FGPropagate::bind(void)
|
|||
PropertyManager->Tie("velocities/eci-velocity-mag-fps", this, &FGPropagate::GetInertialVelocityMagnitude);
|
||||
PropertyManager->Tie("velocities/ned-velocity-mag-fps", this, &FGPropagate::GetNEDVelocityMagnitude);
|
||||
|
||||
PropertyManager->Tie("position/h-sl-ft", this, &FGPropagate::GetAltitudeASL, &FGPropagate::SetAltitudeASL, false);
|
||||
PropertyManager->Tie("position/h-sl-meters", this, &FGPropagate::GetAltitudeASLmeters, &FGPropagate::SetAltitudeASLmeters, false);
|
||||
PropertyManager->Tie("position/lat-gc-rad", this, &FGPropagate::GetLatitude, &FGPropagate::SetLatitude, false);
|
||||
PropertyManager->Tie("position/long-gc-rad", this, &FGPropagate::GetLongitude, &FGPropagate::SetLongitude, false);
|
||||
PropertyManager->Tie("position/lat-gc-deg", this, &FGPropagate::GetLatitudeDeg, &FGPropagate::SetLatitudeDeg, false);
|
||||
PropertyManager->Tie("position/long-gc-deg", this, &FGPropagate::GetLongitudeDeg, &FGPropagate::SetLongitudeDeg, false);
|
||||
PropertyManager->Tie("position/h-sl-ft", this, &FGPropagate::GetAltitudeASL, &FGPropagate::SetAltitudeASL);
|
||||
PropertyManager->Tie("position/h-sl-meters", this, &FGPropagate::GetAltitudeASLmeters, &FGPropagate::SetAltitudeASLmeters);
|
||||
PropertyManager->Tie("position/lat-gc-rad", this, &FGPropagate::GetLatitude, &FGPropagate::SetLatitude);
|
||||
PropertyManager->Tie("position/long-gc-rad", this, &FGPropagate::GetLongitude, &FGPropagate::SetLongitude);
|
||||
PropertyManager->Tie("position/lat-gc-deg", this, &FGPropagate::GetLatitudeDeg, &FGPropagate::SetLatitudeDeg);
|
||||
PropertyManager->Tie("position/long-gc-deg", this, &FGPropagate::GetLongitudeDeg, &FGPropagate::SetLongitudeDeg);
|
||||
PropertyManager->Tie("position/lat-geod-rad", this, &FGPropagate::GetGeodLatitudeRad);
|
||||
PropertyManager->Tie("position/lat-geod-deg", this, &FGPropagate::GetGeodLatitudeDeg);
|
||||
PropertyManager->Tie("position/geod-alt-ft", this, &FGPropagate::GetGeodeticAltitude);
|
||||
PropertyManager->Tie("position/h-agl-ft", this, &FGPropagate::GetDistanceAGL, &FGPropagate::SetDistanceAGL, false);
|
||||
PropertyManager->Tie("position/h-agl-ft", this, &FGPropagate::GetDistanceAGL, &FGPropagate::SetDistanceAGL);
|
||||
PropertyManager->Tie("position/geod-alt-km", this, &FGPropagate::GetGeodeticAltitudeKm);
|
||||
PropertyManager->Tie("position/h-agl-km", this, &FGPropagate::GetDistanceAGLKm, &FGPropagate::SetDistanceAGLKm, false);
|
||||
PropertyManager->Tie("position/h-agl-km", this, &FGPropagate::GetDistanceAGLKm, &FGPropagate::SetDistanceAGLKm);
|
||||
PropertyManager->Tie("position/radius-to-vehicle-ft", this, &FGPropagate::GetRadius);
|
||||
PropertyManager->Tie("position/terrain-elevation-asl-ft", this,
|
||||
&FGPropagate::GetTerrainElevation,
|
||||
&FGPropagate::SetTerrainElevation, false);
|
||||
&FGPropagate::SetTerrainElevation);
|
||||
|
||||
PropertyManager->Tie("position/eci-x-ft", this, eX, (PMF)&FGPropagate::GetInertialPosition);
|
||||
PropertyManager->Tie("position/eci-y-ft", this, eY, (PMF)&FGPropagate::GetInertialPosition);
|
||||
|
|
|
@ -804,7 +804,7 @@ void FGPropulsion::bind(void)
|
|||
typedef int (FGPropulsion::*iPMF)(void) const;
|
||||
|
||||
IsBound = true;
|
||||
PropertyManager->Tie("propulsion/set-running", this, (iPMF)0, &FGPropulsion::InitRunning, false);
|
||||
PropertyManager->Tie("propulsion/set-running", this, (iPMF)0, &FGPropulsion::InitRunning);
|
||||
if (HaveTurbineEngine || HaveTurboPropEngine) {
|
||||
PropertyManager->Tie("propulsion/starter_cmd", this, &FGPropulsion::GetStarter, &FGPropulsion::SetStarter);
|
||||
PropertyManager->Tie("propulsion/cutoff_cmd", this, &FGPropulsion::GetCutoff, &FGPropulsion::SetCutoff);
|
||||
|
@ -812,11 +812,11 @@ void FGPropulsion::bind(void)
|
|||
|
||||
if (HavePistonEngine) {
|
||||
PropertyManager->Tie("propulsion/starter_cmd", this, &FGPropulsion::GetStarter, &FGPropulsion::SetStarter);
|
||||
PropertyManager->Tie("propulsion/magneto_cmd", this, (iPMF)0, &FGPropulsion::SetMagnetos, false);
|
||||
PropertyManager->Tie("propulsion/magneto_cmd", this, (iPMF)0, &FGPropulsion::SetMagnetos);
|
||||
}
|
||||
|
||||
PropertyManager->Tie("propulsion/active_engine", this, (iPMF)&FGPropulsion::GetActiveEngine,
|
||||
&FGPropulsion::SetActiveEngine, true);
|
||||
&FGPropulsion::SetActiveEngine);
|
||||
PropertyManager->Tie("forces/fbx-prop-lbs", this, eX, (PMF)&FGPropulsion::GetForces);
|
||||
PropertyManager->Tie("forces/fby-prop-lbs", this, eY, (PMF)&FGPropulsion::GetForces);
|
||||
PropertyManager->Tie("forces/fbz-prop-lbs", this, eZ, (PMF)&FGPropulsion::GetForces);
|
||||
|
|
Loading…
Reference in a new issue