]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGPropertyManager.cpp
Make yasim accept the launchbar and hook properties. They are not tied to anything...
[flightgear.git] / src / FDM / JSBSim / FGPropertyManager.cpp
index 09337b899d6734d50215a6a49c98d947adc8d485..42d632d4b5927ccaa442bbe992e52e32eb236055 100644 (file)
@@ -1,22 +1,22 @@
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
  Header:       FGPropertyManager.cpp
  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.
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#include <simgear/misc/props.hxx>
 #include "FGPropertyManager.h"
 
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+DEFINITIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -43,38 +46,48 @@ COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 */
 
+namespace JSBSim {
+
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 string FGPropertyManager::mkPropertyName(string name, bool lowercase) {
-  
-  for(unsigned i=0;i<name.length();i++) {
+
+  /* do this two pass to avoid problems with characters getting skipped
+     because the index changed */
+  unsigned i;
+  for(i=0;i<name.length();i++) {
     if( lowercase && isupper(name[i]) )
       name[i]=tolower(name[i]);
-    else if( isspace(name[i]) ) 
+    else if( isspace(name[i]) )
       name[i]='-';
   }
+  for(i=0;i<name.length();i++) {
+    if( name[i] == '/' )
+      name.erase(i,1);
+  }
+
   return name;
 }
-  
+
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-FGPropertyManager*  
+FGPropertyManager*
 FGPropertyManager::GetNode (const string &path, bool create)
 {
   SGPropertyNode* node=this->getNode(path.c_str(), create);
-  if(node == 0) 
-    cout << "FGPropertyManager::GetNode() No node found for " 
-         << path << endl;
+  //if(node == 0)
+  //  cout << "FGPropertyManager::GetNode() No node found for "
+  //       << path << endl;
   return (FGPropertyManager*)node;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-FGPropertyManager* 
+FGPropertyManager*
 FGPropertyManager::GetNode (const string &relpath, int index, bool create)
 {
     return (FGPropertyManager*)getNode(relpath.c_str(),index,create);
-}    
+}
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
@@ -88,7 +101,33 @@ bool FGPropertyManager::HasNode (const string &path)
 
 string FGPropertyManager::GetName( void ) {
   return string( getName() );
-}  
+}
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+string FGPropertyManager::GetFullyQualifiedName(void) {
+    vector<string> stack;
+    stack.push_back( getDisplayName(true) );
+    SGPropertyNode* tmpn=getParent();
+    bool atroot=false;
+    while( !atroot ) {
+     stack.push_back( tmpn->getDisplayName(true) );
+     if( !tmpn->getParent() )
+      atroot=true;
+     else
+      tmpn=tmpn->getParent();
+    }
+
+    string fqname="";
+    for(unsigned i=stack.size()-1;i>0;i--) {
+      fqname+= stack[i];
+      fqname+= "/";
+    }
+    fqname+= stack[0];
+    return fqname;
+
+}
+
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
@@ -181,8 +220,8 @@ void FGPropertyManager::SetArchivable (const string &name, bool state )
   SGPropertyNode * node = getNode(name.c_str());
   if (node == 0)
     cout <<
-          "Attempt to set archive flag for non-existant property "
-          << name << endl;
+           "Attempt to set archive flag for non-existant property "
+           << name << endl;
   else
     node->setAttribute(SGPropertyNode::ARCHIVE, state);
 }
@@ -194,8 +233,8 @@ void FGPropertyManager::SetReadable (const string &name, bool state )
   SGPropertyNode * node = getNode(name.c_str());
   if (node == 0)
     cout <<
-          "Attempt to set read flag for non-existant property "
-          << name << endl;
+           "Attempt to set read flag for non-existant property "
+           << name << endl;
   else
     node->setAttribute(SGPropertyNode::READ, state);
 }
@@ -207,8 +246,8 @@ void FGPropertyManager::SetWritable (const string &name, bool state )
   SGPropertyNode * node = getNode(name.c_str());
   if (node == 0)
     cout <<
-          "Attempt to set write flag for non-existant property "
-          << name << endl;
+           "Attempt to set write flag for non-existant property "
+           << name << endl;
   else
     node->setAttribute(SGPropertyNode::WRITE, state);
 }
@@ -226,51 +265,53 @@ void FGPropertyManager::Untie (const string &name)
 void FGPropertyManager::Tie (const string &name, bool *pointer, bool useDefault)
 {
   if (!tie(name.c_str(), SGRawValuePointer<bool>(pointer),
-                                useDefault))
+                                 useDefault))
     cout <<
-          "Failed to tie property " << name << " to a pointer" << endl;
+           "Failed to tie property " << name << " to a pointer" << endl;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGPropertyManager::Tie (const string &name, int *pointer, 
+void FGPropertyManager::Tie (const string &name, int *pointer,
                                           bool useDefault )
 {
   if (!tie(name.c_str(), SGRawValuePointer<int>(pointer),
-                                useDefault))
+                                 useDefault))
     cout <<
-          "Failed to tie property " << name << " to a pointer" << endl;
+           "Failed to tie property " << name << " to a pointer" << endl;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGPropertyManager::Tie (const string &name, long *pointer, 
+void FGPropertyManager::Tie (const string &name, long *pointer,
                                           bool useDefault )
 {
   if (!tie(name.c_str(), SGRawValuePointer<long>(pointer),
-                                useDefault))
+                                 useDefault))
     cout <<
-          "Failed to tie property " << name << " to a pointer" << endl;
+           "Failed to tie property " << name << " to a pointer" << endl;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGPropertyManager::Tie (const string &name, float *pointer, 
+void FGPropertyManager::Tie (const string &name, float *pointer,
                                           bool useDefault )
 {
   if (!tie(name.c_str(), SGRawValuePointer<float>(pointer),
-                                useDefault))
+                                 useDefault))
     cout <<
-          "Failed to tie property " << name << " to a pointer" << endl;
+           "Failed to tie property " << name << " to a pointer" << endl;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-void FGPropertyManager::Tie (const string &name, double *pointer, 
+void FGPropertyManager::Tie (const string &name, double *pointer,
                                            bool useDefault)
 {
   if (!tie(name.c_str(), SGRawValuePointer<double>(pointer),
-                                useDefault))
+                                 useDefault))
     cout <<
-          "Failed to tie property " << name << " to a pointer" << endl;
+           "Failed to tie property " << name << " to a pointer" << endl;
 }
+
+} // namespace JSBSim