]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/FGPropertyManager.cpp
Encapsulate the interpolstion version of FGEnvironment and fix some bugs
[flightgear.git] / src / FDM / JSBSim / FGPropertyManager.cpp
index 09337b899d6734d50215a6a49c98d947adc8d485..84eb466566d516fd5d9a859ccce6cbb45be3d4cd 100644 (file)
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
-#include <simgear/misc/props.hxx>
+#include <simgear/props/props.hxx>
 #include "FGPropertyManager.h"
 
+/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+DEFINITIONS
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
+
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 FORWARD DECLARATIONS
@@ -43,19 +47,29 @@ 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]) ) 
       name[i]='-';
   }
+  for(i=0;i<name.length();i++) {
+    if( name[i] == '/' )
+      name.erase(i,1);  
+  }
+
   return name;
 }
-  
+
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 FGPropertyManager*  
@@ -90,6 +104,32 @@ 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;  
+
+}    
+    
+    
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 bool FGPropertyManager::GetBool (const string &name, bool defaultValue)
@@ -274,3 +314,5 @@ void FGPropertyManager::Tie (const string &name, double *pointer,
     cout <<
           "Failed to tie property " << name << " to a pointer" << endl;
 }
+
+} // namespace JSBSim