+
+/**
+ * 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.
+ *
+ * @param name The property name.
+ * @param defaultValue The default value to return if the property
+ * does not exist.
+ * @return The property's value as a float, or the default value provided.
+ */
+extern 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.
+ *
+ * @param name The property name.
+ * @param defaultValue The default value to return if the property
+ * does not exist.
+ * @return The property's value as a float, or the default value provided.
+ */
+inline float fgGetFloat (const std::string & name, float defaultValue = 0.0)
+{
+ return fgGetFloat( name.c_str(), defaultValue );
+}
+
+
+/**
+ * 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.
+ *
+ * @param name The property name.
+ * @param defaultValue The default value to return if the property
+ * does not exist.
+ * @return The property's value as a double, or the default value provided.
+ */
+extern 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.
+ *
+ * @param name The property name.
+ * @param defaultValue The default value to return if the property
+ * does not exist.
+ * @return The property's value as a double, or the default value provided.
+ */
+inline double fgGetDouble (const std::string & name, double defaultValue = 0.0)
+{
+ return fgGetDouble( name.c_str(), defaultValue );
+}
+
+
+/**
+ * Get a string 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 getStringValue() method, to avoid the lookup overhead.
+ *
+ * @param name The property name.
+ * @param defaultValue The default value to return if the property
+ * does not exist.
+ * @return The property's value as a string, or the default value provided.
+ */
+extern const char * fgGetString (const char * name,
+ const char * defaultValue = "");
+
+/**
+ * Get a string 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 getStringValue() method, to avoid the lookup overhead.
+ *
+ * @param name The property name.
+ * @param defaultValue The default value to return if the property
+ * does not exist.
+ * @return The property's value as a string, or the default value provided.
+ */
+inline const char * fgGetString (const std::string & name,
+ const std::string & defaultValue = std::string(""))
+{
+ return fgGetString( name.c_str(), defaultValue.c_str() );
+}
+
+
+/**
+ * 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.
+ *
+ * @param name The property name.
+ * @param val The new value for the property.
+ * @return true if the assignment succeeded, false otherwise.
+ */
+extern 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.
+ *
+ * @param name The property name.
+ * @param val The new value for the property.
+ * @return true if the assignment succeeded, false otherwise.
+ */
+inline bool fgSetBool (const std::string & name, bool val)
+{
+ return fgSetBool( name.c_str(), val );
+}
+
+
+/**
+ * Set an int value for a property.
+ *
+ * Assign an int value to a property. If the property does not
+ * yet exist, it will be created and its type will be set to
+ * INT; if it has a type of UNKNOWN, the type will also be set to
+ * INT; otherwise, the bool value will be converted to the property's
+ * type.
+ *
+ * @param name The property name.
+ * @param val The new value for the property.
+ * @return true if the assignment succeeded, false otherwise.
+ */
+extern bool fgSetInt (const char * name, int val);
+
+/**
+ * Set an int value for a property.
+ *
+ * Assign an int value to a property. If the property does not
+ * yet exist, it will be created and its type will be set to
+ * INT; if it has a type of UNKNOWN, the type will also be set to
+ * INT; otherwise, the bool value will be converted to the property's
+ * type.
+ *
+ * @param name The property name.
+ * @param val The new value for the property.
+ * @return true if the assignment succeeded, false otherwise.
+ */
+inline bool fgSetInt (const std::string & name, int val)
+{
+ return fgSetInt( name.c_str(), val );
+}
+
+/**
+ * Set a long value for a property.
+ *
+ * Assign a long value to a property. If the property does not
+ * yet exist, it will be created and its type will be set to
+ * LONG; if it has a type of UNKNOWN, the type will also be set to
+ * LONG; otherwise, the bool value will be converted to the property's
+ * type.
+ *
+ * @param name The property name.
+ * @param val The new value for the property.
+ * @return true if the assignment succeeded, false otherwise.
+ */
+extern bool fgSetLong (const char * name, long val);
+
+/**
+ * Set a long value for a property.
+ *
+ * Assign a long value to a property. If the property does not
+ * yet exist, it will be created and its type will be set to
+ * LONG; if it has a type of UNKNOWN, the type will also be set to
+ * LONG; otherwise, the bool value will be converted to the property's
+ * type.
+ *
+ * @param name The property name.
+ * @param val The new value for the property.
+ * @return true if the assignment succeeded, false otherwise.
+ */
+inline bool fgSetLong (const std::string & name, long val)
+{
+ return fgSetLong( name.c_str(), 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.
+ *
+ * @param name The property name.
+ * @param val The new value for the property.
+ * @return true if the assignment succeeded, false otherwise.
+ */
+extern 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.
+ *
+ * @param name The property name.
+ * @param val The new value for the property.
+ * @return true if the assignment succeeded, false otherwise.
+ */
+inline bool fgSetFloat (const std::string & name, float val)
+{
+ return fgSetFloat( name.c_str(), 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.
+ *
+ * @param name The property name.
+ * @param val The new value for the property.
+ * @return true if the assignment succeeded, false otherwise.
+ */
+extern 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.
+ *
+ * @param name The property name.
+ * @param val The new value for the property.
+ * @return true if the assignment succeeded, false otherwise.
+ */
+inline bool fgSetDouble (const std::string & name, double val)
+{
+ return fgSetDouble( name.c_str(), 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.
+ *
+ * @param name The property name.
+ * @param val The new value for the property.
+ * @return true if the assignment succeeded, false otherwise.
+ */
+extern 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.
+ *
+ * @param name The property name.
+ * @param val The new value for the property.
+ * @return true if the assignment succeeded, false otherwise.
+ */
+inline bool fgSetString (const std::string & name, const std::string & val)
+{
+ return fgSetString( name.c_str(), val.c_str() );
+}
+
+
+\f
+////////////////////////////////////////////////////////////////////////
+// Convenience functions for setting property attributes.
+////////////////////////////////////////////////////////////////////////
+
+
+/**
+ * Set the state of the archive attribute for a property.
+ *
+ * If the archive attribute is true, the property will be written
+ * when a flight is saved; if it is false, the property will be
+ * skipped.
+ *
+ * A warning message will be printed if the property does not exist.
+ *
+ * @param name The property name.
+ * @param state The state of the archive attribute (defaults to true).
+ */
+extern void fgSetArchivable (const char * name, bool state = true);
+
+
+/**
+ * Set the state of the read attribute for a property.
+ *
+ * If the read attribute is true, the property value will be readable;
+ * if it is false, the property value will always be the default value
+ * for its type.
+ *
+ * A warning message will be printed if the property does not exist.
+ *
+ * @param name The property name.
+ * @param state The state of the read attribute (defaults to true).
+ */
+extern void fgSetReadable (const char * name, bool state = true);
+
+
+/**
+ * Set the state of the write attribute for a property.
+ *
+ * If the write attribute is true, the property value may be modified
+ * (depending on how it is tied); if the write attribute is false, the
+ * property value may not be modified.
+ *
+ * A warning message will be printed if the property does not exist.
+ *
+ * @param name The property name.
+ * @param state The state of the write attribute (defaults to true).
+ */
+extern void fgSetWritable (const char * name, bool state = true);
+
+
+\f
+////////////////////////////////////////////////////////////////////////
+// Convenience functions for tying properties, with logging.
+////////////////////////////////////////////////////////////////////////
+
+
+/**
+ * Untie a property from an external data source.
+ *
+ * Classes should use this function to release control of any
+ * properties they are managing.
+ */
+extern void fgUntie (const char * name);
+
+
+/**
+ * Tie a property to a pair of simple functions.
+ *
+ * Every time the property value is queried, the getter (if any) will
+ * be invoked; every time the property value is modified, the setter
+ * (if any) will be invoked. The getter can be 0 to make the property
+ * unreadable, and the setter can be 0 to make the property
+ * unmodifiable.
+ *
+ * @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.
+ */