Board index FlightGear Development

PropertyManager-Implementation  Topic is solved

FlightGear is opensource, so you can be the developer. In the need for help on anything? We are here to help you.
Forum rules
Core development is discussed on the official FlightGear-Devel development mailing list.

Bugs can be reported in the bug tracker.

PropertyManager-Implementation  

Postby gierschi@flightgear » Mon Jan 04, 2016 1:19 pm

Hey,
can you help me to understand the code a little bit more?! In many files of the source code (e.g. FGWinds.cpp) I find something like this:

typedef double (FGWinds::*PMF)(int) const;
typedef int (FGWinds::*PMFt)(void) const;
typedef void (FGWinds::*PMFd)(int,double);
typedef void (FGWinds::*PMFi)(int);
typedef double (FGWinds::*Ptr)(void) const;

// User-specified steady, constant, wind properties (local navigational/geographic frame: N-E-D)
PropertyManager->Tie("atmosphere/psiw-rad", this, &FGWinds::GetWindPsi, &FGWinds::SetWindPsi);
PropertyManager->Tie("atmosphere/wind-north-fps", this, eNorth, (PMF)&FGWinds::GetWindNED,
(PMFd)&FGWinds::SetWindNED);
PropertyManager->Tie("atmosphere/wind-east-fps", this, eEast, (PMF)&FGWinds::GetWindNED,
(PMFd)&FGWinds::SetWindNED);
PropertyManager->Tie("atmosphere/wind-down-fps", this, eDown, (PMF)&FGWinds::GetWindNED,
(PMFd)&FGWinds::SetWindNED);
PropertyManager->Tie("atmosphere/wind-mag-fps", this, &FGWinds::GetWindspeed,
&FGWinds::SetWindspeed);
...

I don't really understand what is happening here. With my c++ knowledge I think that at the beginning new types called e.g. PMF are defined which refer to a pointer to a function. Later the PropertyManager is an Pointer to an object which activate the function Tie. Where is the PropertyManager defined? The function Tie seems to need some Inpurparameter like a path and always the Parameter this and so on. Sometimes you find the new types (e. g. PMFd) in this Parameterlist, too. I don't understand the connection between all this. Do I need to look into antoher file? Maybe some of you can explain what happens here and why it is implement in the code? Thank you very much in advance.

Best regards,
Sebastian

PS.: The Wikipedia entry under the topic PropertyManager didn't help me very much.
gierschi@flightgear
 
Posts: 58
Joined: Tue Nov 03, 2015 10:40 pm

Re: PropertyManager-Implementation

Postby Hooray » Mon Jan 04, 2016 6:53 pm

You will find most of questions answered by checking the FlightGear wiki, specifically:

http://wiki.flightgear.org/Property_tree
http://wiki.flightgear.org/Howto:Use_Pr ... ee_Objects

The relevant keywords are "SGPropertyNode" and "tied properties".

http://api-docs.freeflightsim.org/simge ... yNode.html

Regarding typedef, please check any C++ tutorial to learn how this works - but basically you are right, a new type is introduced so that you can use it as an "alias" (short-hand) for the expression.

To understand the code in question, you will need to understand 1) pointers, 2) classes, 3) references, 4) taking an object's/method's address, 5) type-casting

It might be better/easier to tell us exactly what it is that you want to do
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: PropertyManager-Implementation

Postby gierschi@flightgear » Fri Jan 08, 2016 3:30 pm

I think that helps first of all. Thanks :-)!
gierschi@flightgear
 
Posts: 58
Joined: Tue Nov 03, 2015 10:40 pm

Re: PropertyManager-Implementation

Postby Hooray » Fri Jan 08, 2016 8:11 pm

you could also tell us what you are trying to do, and we may be able to provide more specific advice
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU


Return to Development

Who is online

Users browsing this forum: No registered users and 7 guests