namespace JSBSim {
bool FGPropertyManager::suppress_warning = true;
+std::vector<SGPropertyNode_ptr> FGPropertyManager::tied_properties;
+
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+void FGPropertyManager::Unbind(void)
+{
+ vector<SGPropertyNode_ptr>::iterator it;
+
+ for (it = tied_properties.begin();it < tied_properties.end();it++)
+ (*it)->untie();
+
+ tied_properties.clear();
+}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{
SGPropertyNode* node=this->getNode(path.c_str(), create);
if (node == 0 && !suppress_warning) {
- cout << "FGPropertyManager::GetNode() No node found for " << path << endl;
+ cerr << "FGPropertyManager::GetNode() No node found for " << path << endl;
}
return (FGPropertyManager*)node;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
bool FGPropertyManager::HasNode (const string &path)
{
// Checking if a node exists shouldn't write a warning if it doesn't exist
}
+//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+string FGPropertyManager::GetRelativeName( const string &path )
+{
+ string temp_string = GetFullyQualifiedName();
+ size_t len = path.length();
+ if ( (len > 0) && (temp_string.substr(0,len) == path) ) {
+ temp_string = temp_string.erase(0,len);
+ }
+ return temp_string;
+}
+
+
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{
SGPropertyNode * node = getNode(name.c_str());
if (node == 0)
- cout <<
- "Attempt to set archive flag for non-existant property "
+ cerr <<
+ "Attempt to set archive flag for non-existent property "
<< name << endl;
else
node->setAttribute(SGPropertyNode::ARCHIVE, state);
{
SGPropertyNode * node = getNode(name.c_str());
if (node == 0)
- cout <<
+ cerr <<
"Attempt to set read flag for non-existant property "
<< name << endl;
else
{
SGPropertyNode * node = getNode(name.c_str());
if (node == 0)
- cout <<
+ cerr <<
"Attempt to set write flag for non-existant property "
<< name << endl;
else
void FGPropertyManager::Untie (const string &name)
{
if (!untie(name.c_str()))
- cout << "Failed to untie property " << name << endl;
+ cerr << "Failed to untie property " << name << endl;
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGPropertyManager::Tie (const string &name, bool *pointer, bool useDefault)
{
- if (!tie(name.c_str(), SGRawValuePointer<bool>(pointer), useDefault))
- cout << "Failed to tie property " << name << " to a pointer" << endl;
- else if (debug_lvl & 0x20)
- cout << name << endl;
+ SGPropertyNode* property = getNode(name.c_str(), true);
+ if (!property) {
+ cerr << "Could not get or create property " << name << endl;
+ return;
+ }
+
+ if (!property->tie(SGRawValuePointer<bool>(pointer), useDefault))
+ cerr << "Failed to tie property " << name << " to a pointer" << endl;
+ else {
+ tied_properties.push_back(property);
+ if (debug_lvl & 0x20) cout << name << endl;
+ }
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGPropertyManager::Tie (const string &name, int *pointer,
bool useDefault )
{
- if (!tie(name.c_str(), SGRawValuePointer<int>(pointer), useDefault))
- cout << "Failed to tie property " << name << " to a pointer" << endl;
- else if (debug_lvl & 0x20)
- cout << name << endl;
+ SGPropertyNode* property = getNode(name.c_str(), true);
+ if (!property) {
+ cerr << "Could not get or create property " << name << endl;
+ return;
+ }
+
+ if (!property->tie(SGRawValuePointer<int>(pointer), useDefault))
+ cerr << "Failed to tie property " << name << " to a pointer" << endl;
+ else {
+ tied_properties.push_back(property);
+ if (debug_lvl & 0x20) cout << name << endl;
+ }
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGPropertyManager::Tie (const string &name, long *pointer,
bool useDefault )
{
- if (!tie(name.c_str(), SGRawValuePointer<long>(pointer), useDefault))
- cout << "Failed to tie property " << name << " to a pointer" << endl;
- else if (debug_lvl & 0x20)
- cout << name << endl;
+ SGPropertyNode* property = getNode(name.c_str(), true);
+ if (!property) {
+ cerr << "Could not get or create property " << name << endl;
+ return;
+ }
+
+ if (!property->tie(SGRawValuePointer<long>(pointer), useDefault))
+ cerr << "Failed to tie property " << name << " to a pointer" << endl;
+ else {
+ tied_properties.push_back(property);
+ if (debug_lvl & 0x20) cout << name << endl;
+ }
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGPropertyManager::Tie (const string &name, float *pointer,
bool useDefault )
{
- if (!tie(name.c_str(), SGRawValuePointer<float>(pointer), useDefault))
- cout << "Failed to tie property " << name << " to a pointer" << endl;
- else if (debug_lvl & 0x20)
- cout << name << endl;
+ SGPropertyNode* property = getNode(name.c_str(), true);
+ if (!property) {
+ cerr << "Could not get or create property " << name << endl;
+ return;
+ }
+
+ if (!property->tie(SGRawValuePointer<float>(pointer), useDefault))
+ cerr << "Failed to tie property " << name << " to a pointer" << endl;
+ else {
+ tied_properties.push_back(property);
+ if (debug_lvl & 0x20) cout << name << endl;
+ }
}
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGPropertyManager::Tie (const string &name, double *pointer, bool useDefault)
{
- if (!tie(name.c_str(), SGRawValuePointer<double>(pointer), useDefault))
- cout << "Failed to tie property " << name << " to a pointer" << endl;
- else if (debug_lvl & 0x20)
- cout << name << endl;
+ SGPropertyNode* property = getNode(name.c_str(), true);
+ if (!property) {
+ cerr << "Could not get or create property " << name << endl;
+ return;
+ }
+
+ if (!property->tie(SGRawValuePointer<double>(pointer), useDefault))
+ cerr << "Failed to tie property " << name << " to a pointer" << endl;
+ else {
+ tied_properties.push_back(property);
+ if (debug_lvl & 0x20) cout << name << endl;
+ }
}
} // namespace JSBSim