FlightGear next
proptest.cpp File Reference
#include <stdio.h>
#include <stdlib.h>
#include "yasim-common.hpp"
#include "Math.hpp"
#include "FGFDM.hpp"
#include "PropEngine.hpp"
#include "Propeller.hpp"
#include "Atmosphere.hpp"
#include <simgear/misc/sg_path.hxx>

Go to the source code of this file.

Functions

bool fgSetFloat (const char *name, float val)
 Set a float value for a property.
 
bool fgSetBool (char const *name, bool val)
 Set a bool value for a property.
 
bool fgGetBool (char const *name, bool def)
 Get a bool value for a property.
 
bool fgSetString (char const *name, char const *str)
 Set a string value for a property.
 
SGPropertyNode * fgGetNode (const char *path, bool create)
 Get a property node.
 
SGPropertyNode * fgGetNode (const char *path, int i, bool create)
 Get a property node with separate index.
 
float fgGetFloat (const char *name, float defaultValue)
 Get a float value for a property.
 
double fgGetDouble (const char *name, double defaultValue)
 Get a double value for a property.
 
bool fgSetDouble (const char *name, double defaultValue)
 Set a double value for a property.
 
int main (int argc, char **argv)
 

Variables

const int COUNT = 100
 

Function Documentation

◆ fgGetBool()

bool fgGetBool ( const char * name,
bool defaultValue = false )

Get a bool value for a property.

This method is convenient but inefficient. It should be used infrequently (i.e. for initializing, loading, saving, etc.), not in the main loop. If you need to get a value frequently, it is better to look up the node itself using fgGetNode and then use the node's getBoolValue() method, to avoid the lookup overhead.

Parameters
nameThe property name.
defaultValueThe default value to return if the property does not exist.
Returns
The property's value as a bool, or the default value provided.

Definition at line 25 of file proptest.cpp.

◆ fgGetDouble()

double fgGetDouble ( const char * name,
double defaultValue = 0.0 )

Get a double value for a property.

This method is convenient but inefficient. It should be used infrequently (i.e. for initializing, loading, saving, etc.), not in the main loop. If you need to get a value frequently, it is better to look up the node itself using fgGetNode and then use the node's getDoubleValue() method, to avoid the lookup overhead.

Parameters
nameThe property name.
defaultValueThe default value to return if the property does not exist.
Returns
The property's value as a double, or the default value provided.

Definition at line 30 of file proptest.cpp.

◆ fgGetFloat()

float fgGetFloat ( const char * name,
float defaultValue = 0.0 )

Get a float value for a property.

This method is convenient but inefficient. It should be used infrequently (i.e. for initializing, loading, saving, etc.), not in the main loop. If you need to get a value frequently, it is better to look up the node itself using fgGetNode and then use the node's getFloatValue() method, to avoid the lookup overhead.

Parameters
nameThe property name.
defaultValueThe default value to return if the property does not exist.
Returns
The property's value as a float, or the default value provided.

Definition at line 29 of file proptest.cpp.

◆ fgGetNode() [1/2]

SGPropertyNode * fgGetNode ( const char * path,
bool create = false )

Get a property node.

Parameters
pathThe path of the node, relative to root.
createtrue to create the node if it doesn't exist.
Returns
The node, or 0 if none exists and none was created.

Definition at line 27 of file proptest.cpp.

◆ fgGetNode() [2/2]

SGPropertyNode * fgGetNode ( const char * path,
int index,
bool create = false )

Get a property node with separate index.

This method separates the index from the path string, to make it easier to iterate through multiple components without using sprintf to add indices. For example, fgGetNode("foo[1]/bar", 3) will return the same result as fgGetNode("foo[1]/bar[3]").

Parameters
pathThe path of the node, relative to root.
indexThe index for the last member of the path (overrides any given in the string).
createtrue to create the node if it doesn't exist.
Returns
The node, or 0 if none exists and none was created.

Definition at line 28 of file proptest.cpp.

◆ fgSetBool()

bool fgSetBool ( const char * name,
bool val )

Set a bool value for a property.

Assign a bool value to a property. If the property does not yet exist, it will be created and its type will be set to BOOL; if it has a type of UNKNOWN, the type will also be set to BOOL; otherwise, the bool value will be converted to the property's type.

Parameters
nameThe property name.
valThe new value for the property.
Returns
true if the assignment succeeded, false otherwise.

Definition at line 24 of file proptest.cpp.

◆ fgSetDouble()

bool fgSetDouble ( const char * name,
double val )

Set a double value for a property.

Assign a double value to a property. If the property does not yet exist, it will be created and its type will be set to DOUBLE; if it has a type of UNKNOWN, the type will also be set to DOUBLE; otherwise, the double value will be converted to the property's type.

Parameters
nameThe property name.
valThe new value for the property.
Returns
true if the assignment succeeded, false otherwise.

Definition at line 31 of file proptest.cpp.

◆ fgSetFloat()

bool fgSetFloat ( const char * name,
float val )

Set a float value for a property.

Assign a float value to a property. If the property does not yet exist, it will be created and its type will be set to FLOAT; if it has a type of UNKNOWN, the type will also be set to FLOAT; otherwise, the bool value will be converted to the property's type.

Parameters
nameThe property name.
valThe new value for the property.
Returns
true if the assignment succeeded, false otherwise.

Definition at line 23 of file proptest.cpp.

◆ fgSetString()

bool fgSetString ( const char * name,
const char * val )

Set a string value for a property.

Assign a string value to a property. If the property does not yet exist, it will be created and its type will be set to STRING; if it has a type of UNKNOWN, the type will also be set to STRING; otherwise, the string value will be converted to the property's type.

Parameters
nameThe property name.
valThe new value for the property.
Returns
true if the assignment succeeded, false otherwise.

Definition at line 26 of file proptest.cpp.

◆ main()

int main ( int argc,
char ** argv )

Definition at line 35 of file proptest.cpp.

Variable Documentation

◆ COUNT

const int COUNT = 100

Definition at line 33 of file proptest.cpp.