]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGPropertyManager.h
Fix stall widths for the "auxilliary" (reverse flow) stalls so they
[flightgear.git] / src / FDM / JSBSim / FGPropertyManager.h
index a3051196a2d118a58c7238033c4037f8e9485077..e257e9bc4bf42616bfcbbbb9b01def120a726b12 100644 (file)
@@ -1,29 +1,29 @@
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
  Header:       FGPropertyManager.h
  Author:       Tony Peden
                Based on work originally by David Megginson
  Date:         2/2002
+
  ------------- Copyright (C) 2002 -------------
+
  This program is free software; you can redistribute it and/or modify it under
  the terms of the GNU General Public License as published by the Free Software
  Foundation; either version 2 of the License, or (at your option) any later
  version.
+
  This program is distributed in the hope that it will be useful, but WITHOUT
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
  details.
+
  You should have received a copy of the GNU General Public License along with
  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
  Place - Suite 330, Boston, MA  02111-1307, USA.
 
  Further information about the GNU General Public License can also be found on
  the world wide web at http://www.gnu.org.
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 SENTRY
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
@@ -35,7 +35,12 @@ SENTRY
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#include <simgear/misc/props.hxx>
+#include <string>
+#ifdef FGFS
+#include <simgear/props/props.hxx>
+#else
+#include "simgear/props/props.hxx"
+#endif
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 DEFINITIONS
@@ -49,34 +54,36 @@ FORWARD DECLARATIONS
 
 using namespace std;
 
-/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+namespace JSBSim {
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS DOCUMENTATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 /** Class wrapper for property handling.
     @author David Megginson, Tony Peden
-    @see <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jsbsim/JSBSim/FGPropertyManager.h?rev=HEAD&content-type=text/vnd.viewcvs-markup">
-         Header File </a>
   */
-  
+
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 CLASS DECLARATION
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-class FGPropertyManager:public SGPropertyNode {
+class FGPropertyManager : public SGPropertyNode {
   public:
     /// Constructor
-    FGPropertyManager(void) {
-      
-    }
+    FGPropertyManager(void) {}
     /// Destructor
-    ~FGPropertyManager(void) {
-      
-    }   
+    ~FGPropertyManager(void) {}
+
+    /** Property-ify a name
+     *  replaces spaces with '-' and, optionally, makes name all lower case
+     *  @param name string to change
+     *  @param lowercase true to change all upper case chars to lower
+     *  NOTE: this function changes its argument and thus relies
+     *  on pass by value
+     */
+    string mkPropertyName(string name, bool lowercase);
+
     /**
      * Get a property node.
      *
@@ -84,22 +91,11 @@ class FGPropertyManager:public SGPropertyNode {
      * @param create true to create the node if it doesn't exist.
      * @return The node, or 0 if none exists and none was created.
      */
-    inline FGPropertyManager* 
-    GetNode (const string &path, bool create = false)
-    {
-      SGPropertyNode* node=this->getNode(path.c_str(), create);
-      if(node == 0) 
-        cout << "FGPropertyManager::GetNode() No node found for " 
-             << path << endl;
-      return (FGPropertyManager*)node;
-    }
-  
-    inline FGPropertyManager* 
-    GetNode (const string &relpath, int index, bool create = false)
-    {
-        return (FGPropertyManager*)getNode(relpath.c_str(),index,create);
-    }    
+    FGPropertyManager*
+    GetNode (const string &path, bool create = false);
 
+    FGPropertyManager*
+    GetNode (const string &relpath, int index, bool create = false);
 
     /**
      * Test whether a given node exists.
@@ -107,12 +103,18 @@ class FGPropertyManager:public SGPropertyNode {
      * @param path The path of the node, relative to root.
      * @return true if the node exists, false otherwise.
      */
-    inline bool
-    HasNode (const string &path)
-    {
-      return (GetNode(path, false) != 0);
-    }
+    bool HasNode (const string &path);
 
+    /**
+     * Get the name of a node
+     */
+    string GetName( void );
+
+    /**
+     * Get the fully qualified name of a node
+     * This function is very slow, so is probably useful for debugging only.
+     */
+    string GetFullyQualifiedName(void);
 
     /**
      * Get a bool value for a property.
@@ -128,10 +130,7 @@ class FGPropertyManager:public SGPropertyNode {
      *        does not exist.
      * @return The property's value as a bool, or the default value provided.
      */
-    inline bool GetBool (const string &name, bool defaultValue = false)
-    {
-      return getBoolValue(name.c_str(), defaultValue);
-    }
+    bool GetBool (const string &name, bool defaultValue = false);
 
 
     /**
@@ -148,10 +147,7 @@ class FGPropertyManager:public SGPropertyNode {
      *        does not exist.
      * @return The property's value as an int, or the default value provided.
      */
-    inline int GetInt (const string &name, int defaultValue = 0)
-    {
-      return getIntValue(name.c_str(), defaultValue);
-    }
+    int GetInt (const string &name, int defaultValue = 0);
 
 
     /**
@@ -168,10 +164,7 @@ class FGPropertyManager:public SGPropertyNode {
      *        does not exist.
      * @return The property's value as a long, or the default value provided.
      */
-    inline int GetLong (const string &name, long defaultValue = 0L)
-    {
-      return getLongValue(name.c_str(), defaultValue);
-    }
+    int GetLong (const string &name, long defaultValue = 0L);
 
 
     /**
@@ -188,10 +181,7 @@ class FGPropertyManager:public SGPropertyNode {
      *        does not exist.
      * @return The property's value as a float, or the default value provided.
      */
-    inline float GetFloat (const string &name, float defaultValue = 0.0)
-    {
-      return getFloatValue(name.c_str(), defaultValue);
-    }
+    float GetFloat (const string &name, float defaultValue = 0.0);
 
 
     /**
@@ -208,10 +198,7 @@ class FGPropertyManager:public SGPropertyNode {
      *        does not exist.
      * @return The property's value as a double, or the default value provided.
      */
-    inline double GetDouble (const string &name, double defaultValue = 0.0)
-    {
-      return getDoubleValue(name.c_str(), defaultValue);
-    }
+    double GetDouble (const string &name, double defaultValue = 0.0);
 
 
     /**
@@ -228,10 +215,7 @@ class FGPropertyManager:public SGPropertyNode {
      *        does not exist.
      * @return The property's value as a string, or the default value provided.
      */
-    inline string GetString (const string &name, string defaultValue = "")
-    {
-      return string(getStringValue(name.c_str(), defaultValue.c_str()));
-    }
+    string GetString (const string &name, string defaultValue = "");
 
 
     /**
@@ -247,10 +231,7 @@ class FGPropertyManager:public SGPropertyNode {
      * @param val The new value for the property.
      * @return true if the assignment succeeded, false otherwise.
      */
-    inline bool SetBool (const string &name, bool val)
-    {
-      return setBoolValue(name.c_str(), val);
-    }
+    bool SetBool (const string &name, bool val);
 
 
     /**
@@ -266,10 +247,7 @@ class FGPropertyManager:public SGPropertyNode {
      * @param val The new value for the property.
      * @return true if the assignment succeeded, false otherwise.
      */
-    inline bool SetInt (const string &name, int val)
-    {
-      return setIntValue(name.c_str(), val);
-    }
+    bool SetInt (const string &name, int val);
 
 
     /**
@@ -285,10 +263,7 @@ class FGPropertyManager:public SGPropertyNode {
      * @param val The new value for the property.
      * @return true if the assignment succeeded, false otherwise.
      */
-    inline bool SetLong (const string &name, long val)
-    {
-      return setLongValue(name.c_str(), val);
-    }
+    bool SetLong (const string &name, long val);
 
 
     /**
@@ -304,10 +279,7 @@ class FGPropertyManager:public SGPropertyNode {
      * @param val The new value for the property.
      * @return true if the assignment succeeded, false otherwise.
      */
-    inline bool SetFloat (const string &name, float val)
-    {
-      return setFloatValue(name.c_str(), val);
-    }
+    bool SetFloat (const string &name, float val);
 
 
     /**
@@ -323,10 +295,7 @@ class FGPropertyManager:public SGPropertyNode {
      * @param val The new value for the property.
      * @return true if the assignment succeeded, false otherwise.
      */
-    inline bool SetDouble (const string &name, double val)
-    {
-      return setDoubleValue(name.c_str(), val);
-    }
+    bool SetDouble (const string &name, double val);
 
 
     /**
@@ -342,13 +311,9 @@ class FGPropertyManager:public SGPropertyNode {
      * @param val The new value for the property.
      * @return true if the assignment succeeded, false otherwise.
      */
-    inline bool SetString (const string &name, const string &val)
-    {
-      return setStringValue(name.c_str(), val.c_str());
-    }
+    bool SetString (const string &name, const string &val);
 
 
-    \f
     ////////////////////////////////////////////////////////////////////////
     // Convenience functions for setting property attributes.
     ////////////////////////////////////////////////////////////////////////
@@ -366,17 +331,7 @@ class FGPropertyManager:public SGPropertyNode {
      * @param name The property name.
      * @param state The state of the archive attribute (defaults to true).
      */
-    inline void
-    SetArchivable (const string &name, bool state = true)
-    {
-      SGPropertyNode * node = getNode(name.c_str());
-      if (node == 0)
-        cout <<
-              "Attempt to set archive flag for non-existant property "
-              << name;
-      else
-        node->setAttribute(SGPropertyNode::ARCHIVE, state);
-    }
+    void SetArchivable (const string &name, bool state = true);
 
 
     /**
@@ -391,17 +346,7 @@ class FGPropertyManager:public SGPropertyNode {
      * @param name The property name.
      * @param state The state of the read attribute (defaults to true).
      */
-    inline void
-    SetReadable (const string &name, bool state = true)
-    {
-      SGPropertyNode * node = getNode(name.c_str());
-      if (node == 0)
-        cout <<
-              "Attempt to set read flag for non-existant property "
-              << name;
-      else
-        node->setAttribute(SGPropertyNode::READ, state);
-    }
+    void SetReadable (const string &name, bool state = true);
 
 
     /**
@@ -416,20 +361,9 @@ class FGPropertyManager:public SGPropertyNode {
      * @param name The property name.
      * @param state The state of the write attribute (defaults to true).
      */
-    inline void
-    SetWritable (const string &name, bool state = true)
-    {
-      SGPropertyNode * node = getNode(name.c_str());
-      if (node == 0)
-        cout <<
-              "Attempt to set write flag for non-existant property "
-              << name;
-      else
-        node->setAttribute(SGPropertyNode::WRITE, state);
-    }
+    void SetWritable (const string &name, bool state = true);
 
 
-    \f
     ////////////////////////////////////////////////////////////////////////
     // Convenience functions for tying properties, with logging.
     ////////////////////////////////////////////////////////////////////////
@@ -441,15 +375,10 @@ class FGPropertyManager:public SGPropertyNode {
      * Classes should use this function to release control of any
      * properties they are managing.
      */
-    inline void
-    Untie (const string &name)
-    {
-      if (!untie(name.c_str()))
-        cout << "Failed to untie property " << name;
-    }
+    void Untie (const string &name);
 
 
-                                   // Templates cause ambiguity here
+        // Templates cause ambiguity here
 
     /**
      * Tie a property to an external bool variable.
@@ -463,14 +392,8 @@ class FGPropertyManager:public SGPropertyNode {
      *        copied to the variable; false if the variable should not
      *        be modified; defaults to true.
      */
-    inline void
-    Tie (const string &name, bool *pointer, bool useDefault = true)
-    {
-      if (!tie(name.c_str(), SGRawValuePointer<bool>(pointer),
-                                    useDefault))
-        cout <<
-              "Failed to tie property " << name << " to a pointer";
-    }
+    void
+    Tie (const string &name, bool *pointer, bool useDefault = true);
 
 
     /**
@@ -485,14 +408,8 @@ class FGPropertyManager:public SGPropertyNode {
      *        copied to the variable; false if the variable should not
      *        be modified; defaults to true.
      */
-    inline void
-    Tie (const string &name, int *pointer, bool useDefault = true)
-    {
-      if (!tie(name.c_str(), SGRawValuePointer<int>(pointer),
-                                    useDefault))
-        cout <<
-              "Failed to tie property " << name << " to a pointer";
-    }
+    void
+    Tie (const string &name, int *pointer, bool useDefault = true);
 
 
     /**
@@ -507,14 +424,8 @@ class FGPropertyManager:public SGPropertyNode {
      *        copied to the variable; false if the variable should not
      *        be modified; defaults to true.
      */
-    inline void
-    Tie (const string &name, long *pointer, bool useDefault = true)
-    {
-      if (!tie(name.c_str(), SGRawValuePointer<long>(pointer),
-                                    useDefault))
-        cout <<
-              "Failed to tie property " << name << " to a pointer";
-    }
+    void
+    Tie (const string &name, long *pointer, bool useDefault = true);
 
 
     /**
@@ -529,15 +440,8 @@ class FGPropertyManager:public SGPropertyNode {
      *        copied to the variable; false if the variable should not
      *        be modified; defaults to true.
      */
-    inline void
-    Tie (const string &name, float *pointer, bool useDefault = true)
-    {
-      if (!tie(name.c_str(), SGRawValuePointer<float>(pointer),
-                                    useDefault))
-        cout <<
-              "Failed to tie property " << name << " to a pointer";
-    }
-
+    void
+    Tie (const string &name, float *pointer, bool useDefault = true);
 
     /**
      * Tie a property to an external double variable.
@@ -551,33 +455,34 @@ class FGPropertyManager:public SGPropertyNode {
      *        copied to the variable; false if the variable should not
      *        be modified; defaults to true.
      */
-    inline void
-    Tie (const string &name, double *pointer, bool useDefault = true)
-    {
-      if (!tie(name.c_str(), SGRawValuePointer<double>(pointer),
-                                    useDefault))
-        cout <<
-              "Failed to tie property " << name << " to a pointer";
-    }
+    void
+    Tie (const string &name, double *pointer, bool useDefault = true);
+
+//============================================================================
+//
+//  All of the following functions *must* be inlined, otherwise linker
+//  errors will result
+//
+//============================================================================
 
     /* template <class V> void
     Tie (const string &name, V (*getter)(), void (*setter)(V) = 0,
            bool useDefault = true);
-    
+
     template <class V> void
     Tie (const 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,
            void (T::*setter)(V) = 0, bool useDefault = true);
 
-    template <class T, class V> void 
+    template <class T, class V> void
     Tie (const string &name, T * obj, int index,
            V (T::*getter)(int) const, void (T::*setter)(int, V) = 0,
            bool useDefault = true); */
 
-/**
+     /**
      * Tie a property to a pair of simple functions.
      *
      * Every time the property value is queried, the getter (if any) will
@@ -589,19 +494,21 @@ class FGPropertyManager:public SGPropertyNode {
      * @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 
+     * @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
+
+    template <class V> inline void
     Tie (const string &name, V (*getter)(), void (*setter)(V) = 0,
-           bool useDefault = true)
+                                              bool useDefault = true)
     {
       if (!tie(name.c_str(), SGRawValueFunctions<V>(getter, setter),
-                                    useDefault))
+         useDefault))
+      {
         cout <<
-              "Failed to tie property " << name << " to functions";
+         "Failed to tie property " << name << " to functions" << endl;
+      }
     }
 
 
@@ -619,22 +526,20 @@ class FGPropertyManager:public SGPropertyNode {
      *        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 
+     * @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 string &name, int index, V (*getter)(int),
+    template <class V> inline void Tie (const 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))
+           SGRawValueFunctionsIndexed<V>(index, getter, setter), useDefault))
+      {
         cout <<
-              "Failed to tie property " << name << " to indexed functions";
+         "Failed to tie property " << name << " to indexed functions" << endl;
+      }
     }
 
 
@@ -653,23 +558,22 @@ class FGPropertyManager:public SGPropertyNode {
      *        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 
+     * @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
+    template <class T, class V> inline void
     Tie (const 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))
+             SGRawValueMethods<T,V>(*obj, getter, setter), useDefault))
+      {
         cout <<
-              "Failed to tie property " << name << " to object methods";
+         "Failed to tie property " << name << " to object methods" << endl;
+      }
     }
 
-
     /**
      * Tie a property to a pair of indexed object methods.
      *
@@ -685,28 +589,23 @@ class FGPropertyManager:public SGPropertyNode {
      *        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 
+     * @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 
+    template <class T, class V> inline void
     Tie (const string &name, T * obj, int index,
            V (T::*getter)(int) const, void (T::*setter)(int, V) = 0,
-           bool useDefault = true)
+                                              bool useDefault = true)
     {
       if (!tie(name.c_str(),
-                                    SGRawValueMethodsIndexed<T,V>(*obj,
-                                                                  index,
-                                                                  getter,
-                                                                  setter),
-                                    useDefault))
+          SGRawValueMethodsIndexed<T,V>(*obj, index, getter, setter), useDefault))
+      {
         cout <<
-              "Failed to tie property " << name << " to indexed object methods";
-    }
-
-};        
-
-
+         "Failed to tie property " << name << " to indexed object methods" << endl;
+      }
+   }
+};
+}
 #endif // FGPROPERTYMANAGER_H