INCLUDES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+// This is needed by MSVC9 when included in FlightGear because of
+// the new Vec4d class in props.hxx
+#if defined( HAVE_CONFIG_H )
+# include <config.h>
+#endif
+
#include <string>
-#include <iostream>
-#include <simgear/props/props.hxx>
+#include "simgear/props/props.hxx"
+#if !PROPS_STANDALONE
+# include "simgear/math/SGMath.hxx"
+#endif
#include "FGJSBBase.h"
DEFINITIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-#define ID_PROPERTYMANAGER "$Id$"
+#define ID_PROPERTYMANAGER "$Id: FGPropertyManager.h,v 1.17 2010/07/08 11:36:28 jberndt Exp $"
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
FORWARD DECLARATIONS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
-using namespace std;
-
namespace JSBSim {
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
* NOTE: this function changes its argument and thus relies
* on pass by value
*/
- string mkPropertyName(string name, bool lowercase);
+ std::string mkPropertyName(std::string name, bool lowercase);
/**
* Get a property node.
* @return The node, or 0 if none exists and none was created.
*/
FGPropertyManager*
- GetNode (const string &path, bool create = false);
+ GetNode (const std::string &path, bool create = false);
FGPropertyManager*
- GetNode (const string &relpath, int index, bool create = false);
+ GetNode (const std::string &relpath, int index, bool create = false);
/**
* Test whether a given node exists.
* @param path The path of the node, relative to root.
* @return true if the node exists, false otherwise.
*/
- bool HasNode (const string &path);
+ bool HasNode (const std::string &path);
/**
* Get the name of a node
*/
- string GetName( void );
+ std::string GetName( void );
/**
* Get the name of a node without underscores, etc.
*/
- string GetPrintableName( void );
+ std::string GetPrintableName( void );
/**
* Get the fully qualified name of a node
* This function is very slow, so is probably useful for debugging only.
*/
- string GetFullyQualifiedName(void);
+ std::string GetFullyQualifiedName(void);
+
+ /**
+ * Get the qualified name of a node relative to given base path,
+ * otherwise the fully qualified name.
+ * This function is very slow, so is probably useful for debugging only.
+ *
+ * @param path The path to strip off, if found.
+ */
+ std::string GetRelativeName( const std::string &path = "/fdm/jsbsim/" );
/**
* Get a bool value for a property.
* does not exist.
* @return The property's value as a bool, or the default value provided.
*/
- bool GetBool (const string &name, bool defaultValue = false);
+ bool GetBool (const std::string &name, bool defaultValue = false);
/**
* does not exist.
* @return The property's value as an int, or the default value provided.
*/
- int GetInt (const string &name, int defaultValue = 0);
+ int GetInt (const std::string &name, int defaultValue = 0);
/**
* does not exist.
* @return The property's value as a long, or the default value provided.
*/
- int GetLong (const string &name, long defaultValue = 0L);
+ int GetLong (const std::string &name, long defaultValue = 0L);
/**
* does not exist.
* @return The property's value as a float, or the default value provided.
*/
- float GetFloat (const string &name, float defaultValue = 0.0);
+ float GetFloat (const std::string &name, float defaultValue = 0.0);
/**
* does not exist.
* @return The property's value as a double, or the default value provided.
*/
- double GetDouble (const string &name, double defaultValue = 0.0);
+ double GetDouble (const std::string &name, double defaultValue = 0.0);
/**
* does not exist.
* @return The property's value as a string, or the default value provided.
*/
- string GetString (const string &name, string defaultValue = "");
+ std::string GetString (const std::string &name, std::string defaultValue = "");
/**
* @param val The new value for the property.
* @return true if the assignment succeeded, false otherwise.
*/
- bool SetBool (const string &name, bool val);
+ bool SetBool (const std::string &name, bool val);
/**
* @param val The new value for the property.
* @return true if the assignment succeeded, false otherwise.
*/
- bool SetInt (const string &name, int val);
+ bool SetInt (const std::string &name, int val);
/**
* @param val The new value for the property.
* @return true if the assignment succeeded, false otherwise.
*/
- bool SetLong (const string &name, long val);
+ bool SetLong (const std::string &name, long val);
/**
* @param val The new value for the property.
* @return true if the assignment succeeded, false otherwise.
*/
- bool SetFloat (const string &name, float val);
+ bool SetFloat (const std::string &name, float val);
/**
* @param val The new value for the property.
* @return true if the assignment succeeded, false otherwise.
*/
- bool SetDouble (const string &name, double val);
+ bool SetDouble (const std::string &name, double val);
/**
* @param val The new value for the property.
* @return true if the assignment succeeded, false otherwise.
*/
- bool SetString (const string &name, const string &val);
+ bool SetString (const std::string &name, const std::string &val);
////////////////////////////////////////////////////////////////////////
* @param name The property name.
* @param state The state of the archive attribute (defaults to true).
*/
- void SetArchivable (const string &name, bool state = true);
+ void SetArchivable (const std::string &name, bool state = true);
/**
* @param name The property name.
* @param state The state of the read attribute (defaults to true).
*/
- void SetReadable (const string &name, bool state = true);
+ void SetReadable (const std::string &name, bool state = true);
/**
* @param name The property name.
* @param state The state of the write attribute (defaults to true).
*/
- void SetWritable (const string &name, bool state = true);
+ void SetWritable (const std::string &name, bool state = true);
////////////////////////////////////////////////////////////////////////
* Classes should use this function to release control of any
* properties they are managing.
*/
- void Untie (const string &name);
+ void Untie (const std::string &name);
// Templates cause ambiguity here
* be modified; defaults to true.
*/
void
- Tie (const string &name, bool *pointer, bool useDefault = true);
+ Tie (const std::string &name, bool *pointer, bool useDefault = true);
/**
* be modified; defaults to true.
*/
void
- Tie (const string &name, int *pointer, bool useDefault = true);
+ Tie (const std::string &name, int *pointer, bool useDefault = true);
/**
* be modified; defaults to true.
*/
void
- Tie (const string &name, long *pointer, bool useDefault = true);
+ Tie (const std::string &name, long *pointer, bool useDefault = true);
/**
* be modified; defaults to true.
*/
void
- Tie (const string &name, float *pointer, bool useDefault = true);
+ Tie (const std::string &name, float *pointer, bool useDefault = true);
/**
* Tie a property to an external double variable.
* be modified; defaults to true.
*/
void
- Tie (const string &name, double *pointer, bool useDefault = true);
+ Tie (const std::string &name, double *pointer, bool useDefault = true);
//============================================================================
//
//============================================================================
/* template <class V> void
- Tie (const string &name, V (*getter)(), void (*setter)(V) = 0,
+ Tie (const std::string &name, V (*getter)(), void (*setter)(V) = 0,
bool useDefault = true);
template <class V> void
- Tie (const string &name, int index, V (*getter)(int),
+ Tie (const std::string &name, int index, V (*getter)(int),
void (*setter)(int, V) = 0, bool useDefault = true);
template <class T, class V> void
- Tie (const string &name, T * obj, V (T::*getter)() const,
+ Tie (const std::string &name, T * obj, V (T::*getter)() const,
void (T::*setter)(V) = 0, bool useDefault = true);
template <class T, class V> void
- Tie (const string &name, T * obj, int index,
+ Tie (const std::string &name, T * obj, int index,
V (T::*getter)(int) const, void (T::*setter)(int, V) = 0,
bool useDefault = true); */
*/
template <class V> inline void
- Tie (const string &name, V (*getter)(), void (*setter)(V) = 0, bool useDefault = true)
+ Tie (const std::string &name, V (*getter)(), void (*setter)(V) = 0, bool useDefault = true)
{
if (!tie(name.c_str(), SGRawValueFunctions<V>(getter, setter), useDefault))
- cout << "Failed to tie property " << name << " to functions" << endl;
+ std::cout << "Failed to tie property " << name << " to functions" << std::endl;
else if (debug_lvl & 0x20)
- cout << name << endl;
+ std::cout << name << std::endl;
}
* property value should there be one; false if the old value should be
* discarded; defaults to true.
*/
- template <class V> inline void Tie (const string &name, int index, V (*getter)(int),
+ template <class V> inline void Tie (const std::string &name, int index, V (*getter)(int),
void (*setter)(int, V) = 0, bool useDefault = true)
{
if (!tie(name.c_str(), SGRawValueFunctionsIndexed<V>(index, getter, setter), useDefault))
- cout << "Failed to tie property " << name << " to indexed functions" << endl;
+ std::cout << "Failed to tie property " << name << " to indexed functions" << std::endl;
else if (debug_lvl & 0x20)
- cout << name << endl;
+ std::cout << name << std::endl;
}
* discarded; defaults to true.
*/
template <class T, class V> inline void
- Tie (const string &name, T * obj, V (T::*getter)() const,
+ Tie (const std::string &name, T * obj, V (T::*getter)() const,
void (T::*setter)(V) = 0, bool useDefault = true)
{
if (!tie(name.c_str(), SGRawValueMethods<T,V>(*obj, getter, setter), useDefault))
- cout << "Failed to tie property " << name << " to object methods" << endl;
+ std::cout << "Failed to tie property " << name << " to object methods" << std::endl;
else if (debug_lvl & 0x20)
- cout << name << endl;
+ std::cout << name << std::endl;
}
/**
* discarded; defaults to true.
*/
template <class T, class V> inline void
- Tie (const string &name, T * obj, int index, V (T::*getter)(int) const,
+ Tie (const std::string &name, T * obj, int index, V (T::*getter)(int) const,
void (T::*setter)(int, V) = 0, bool useDefault = true)
{
if (!tie(name.c_str(), SGRawValueMethodsIndexed<T,V>(*obj, index, getter, setter), useDefault))
- cout << "Failed to tie property " << name << " to indexed object methods" << endl;
+ std::cout << "Failed to tie property " << name << " to indexed object methods" << std::endl;
else if (debug_lvl & 0x20)
- cout << name << endl;
+ std::cout << name << std::endl;
}
};
}