]> git.mxchange.org Git - flightgear.git/blob - src/Main/fg_props.cxx
30c298edbd50fdc9e32990d5b90cd7c66dd333a0
[flightgear.git] / src / Main / fg_props.cxx
1 // fg_props.cxx -- support for FlightGear properties.
2 //
3 // Written by David Megginson, started 2000.
4 //
5 // Copyright (C) 2000, 2001 David Megginson - david@megginson.com
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 //
21 // $Id$
22
23 #ifdef HAVE_CONFIG_H
24 #  include "config.h"
25 #endif
26
27 #include <simgear/compiler.h>
28
29 #include <simgear/structure/exception.hxx>
30 #include <simgear/magvar/magvar.hxx>
31 #include <simgear/timing/sg_time.hxx>
32 #include <simgear/misc/sg_path.hxx>
33 #include <simgear/scene/material/matlib.hxx>
34 #include <simgear/sound/soundmgr_openal.hxx>
35
36 #include STL_IOSTREAM
37
38 #include <Aircraft/aircraft.hxx>
39 #include <Time/tmp.hxx>
40 #include <Environment/environment.hxx>
41
42 #include <GUI/gui.h>
43
44 #include "globals.hxx"
45 #include "fg_props.hxx"
46
47 SG_USING_STD(istream);
48 SG_USING_STD(ostream);
49
50 static bool winding_ccw = true; // FIXME: temporary
51
52 static bool fdm_data_logging = false; // FIXME: temporary
53
54 static bool frozen = false;     // FIXME: temporary
55
56
57 \f
58 ////////////////////////////////////////////////////////////////////////
59 // Default property bindings (not yet handled by any module).
60 ////////////////////////////////////////////////////////////////////////
61
62 struct LogClassMapping {
63   sgDebugClass c;
64   string name;
65   LogClassMapping(sgDebugClass cc, string nname) { c = cc; name = nname; }
66 };
67
68 LogClassMapping log_class_mappings [] = {
69   LogClassMapping(SG_NONE, "none"),
70   LogClassMapping(SG_TERRAIN, "terrain"),
71   LogClassMapping(SG_ASTRO, "astro"),
72   LogClassMapping(SG_FLIGHT, "flight"),
73   LogClassMapping(SG_INPUT, "input"),
74   LogClassMapping(SG_GL, "gl"),
75   LogClassMapping(SG_VIEW, "view"),
76   LogClassMapping(SG_COCKPIT, "cockpit"),
77   LogClassMapping(SG_GENERAL, "general"),
78   LogClassMapping(SG_MATH, "math"),
79   LogClassMapping(SG_EVENT, "event"),
80   LogClassMapping(SG_AIRCRAFT, "aircraft"),
81   LogClassMapping(SG_AUTOPILOT, "autopilot"),
82   LogClassMapping(SG_IO, "io"),
83   LogClassMapping(SG_CLIPPER, "clipper"),
84   LogClassMapping(SG_NETWORK, "network"),
85   LogClassMapping(SG_INSTR, "instrumentation"),
86   LogClassMapping(SG_SYSTEMS, "systems"),
87   LogClassMapping(SG_UNDEFD, "")
88 };
89
90
91 /**
92  * Get the logging classes.
93  */
94 static const char *
95 getLoggingClasses ()
96 {
97   sgDebugClass classes = logbuf::get_log_classes();
98   static string result = "";    // FIXME
99   for (int i = 0; log_class_mappings[i].c != SG_UNDEFD; i++) {
100     if ((classes&log_class_mappings[i].c) > 0) {
101       if (!result.empty())
102         result += '|';
103       result += log_class_mappings[i].name;
104     }
105   }
106   return result.c_str();
107 }
108
109
110 static void
111 addLoggingClass (const string &name)
112 {
113   sgDebugClass classes = logbuf::get_log_classes();
114   for (int i = 0; log_class_mappings[i].c != SG_UNDEFD; i++) {
115     if (name == log_class_mappings[i].name) {
116       logbuf::set_log_classes(sgDebugClass(classes|log_class_mappings[i].c));
117       return;
118     }
119   }
120   SG_LOG(SG_GENERAL, SG_WARN, "Unknown logging class: " << name);
121 }
122
123
124 /**
125  * Set the logging classes.
126  */
127 static void
128 setLoggingClasses (const char * c)
129 {
130   string classes = c;
131   logbuf::set_log_classes(SG_NONE);
132
133   if (classes == "none") {
134     SG_LOG(SG_GENERAL, SG_INFO, "Disabled all logging classes");
135     return;
136   }
137
138   if (classes.empty() || classes == "all") { // default
139     logbuf::set_log_classes(SG_ALL);
140     SG_LOG(SG_GENERAL, SG_INFO, "Enabled all logging classes: "
141            << getLoggingClasses());
142     return;
143   }
144
145   string rest = classes;
146   string name = "";
147   int sep = rest.find('|');
148   while (sep > 0) {
149     name = rest.substr(0, sep);
150     rest = rest.substr(sep+1);
151     addLoggingClass(name);
152     sep = rest.find('|');
153   }
154   addLoggingClass(rest);
155   SG_LOG(SG_GENERAL, SG_INFO, "Set logging classes to "
156          << getLoggingClasses());
157 }
158
159
160 /**
161  * Get the logging priority.
162  */
163 static const char *
164 getLoggingPriority ()
165 {
166   switch (logbuf::get_log_priority()) {
167   case SG_BULK:
168     return "bulk";
169   case SG_DEBUG:
170     return "debug";
171   case SG_INFO:
172     return "info";
173   case SG_WARN:
174     return "warn";
175   case SG_ALERT:
176     return "alert";
177   default:
178     SG_LOG(SG_GENERAL, SG_WARN, "Internal: Unknown logging priority number: "
179            << logbuf::get_log_priority());
180     return "unknown";
181   }
182 }
183
184
185 /**
186  * Set the logging priority.
187  */
188 static void
189 setLoggingPriority (const char * p)
190 {
191   if (p == 0)
192       return;
193   string priority = p;
194   if (priority == "bulk") {
195     logbuf::set_log_priority(SG_BULK);
196   } else if (priority == "debug") {
197     logbuf::set_log_priority(SG_DEBUG);
198   } else if (priority.empty() || priority == "info") { // default
199     logbuf::set_log_priority(SG_INFO);
200   } else if (priority == "warn") {
201     logbuf::set_log_priority(SG_WARN);
202   } else if (priority == "alert") {
203     logbuf::set_log_priority(SG_ALERT);
204   } else {
205     SG_LOG(SG_GENERAL, SG_WARN, "Unknown logging priority " << priority);
206   }
207   SG_LOG(SG_GENERAL, SG_DEBUG, "Logging priority is " << getLoggingPriority());
208 }
209
210
211 /**
212  * Return the current frozen state.
213  */
214 static bool
215 getFreeze ()
216 {
217   return frozen;
218 }
219
220
221 /**
222  * Set the current frozen state.
223  */
224 static void
225 setFreeze (bool f)
226 {
227     frozen = f;
228
229     // Stop sound on a pause
230     SGSoundMgr *s = globals->get_soundmgr();
231     if ( s != NULL ) {
232         if ( f ) {
233             s->pause();
234         } else {
235             s->resume();
236         }
237     }
238 }
239
240
241 /**
242  * Return the number of milliseconds elapsed since simulation started.
243  */
244 static double
245 getElapsedTime_sec ()
246 {
247   return globals->get_sim_time_sec();
248 }
249
250
251 /**
252  * Return the current Zulu time.
253  */
254 static const char *
255 getDateString ()
256 {
257   static char buf[64];          // FIXME
258   struct tm * t = globals->get_time_params()->getGmt();
259   sprintf(buf, "%.4d-%.2d-%.2dT%.2d:%.2d:%.2d",
260           t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
261           t->tm_hour, t->tm_min, t->tm_sec);
262   return buf;
263 }
264
265
266 /**
267  * Set the current Zulu time.
268  */
269 static void
270 setDateString (const char * date_string)
271 {
272   static const SGPropertyNode *cur_time_override
273         = fgGetNode("/sim/time/cur-time-override", true);
274
275   SGTime * st = globals->get_time_params();
276   struct tm * current_time = st->getGmt();
277   struct tm new_time;
278
279                                 // Scan for basic ISO format
280                                 // YYYY-MM-DDTHH:MM:SS
281   int ret = sscanf(date_string, "%d-%d-%dT%d:%d:%d",
282                    &(new_time.tm_year), &(new_time.tm_mon),
283                    &(new_time.tm_mday), &(new_time.tm_hour),
284                    &(new_time.tm_min), &(new_time.tm_sec));
285
286                                 // Be pretty picky about this, so
287                                 // that strange things don't happen
288                                 // if the save file has been edited
289                                 // by hand.
290   if (ret != 6) {
291     SG_LOG(SG_INPUT, SG_WARN, "Date/time string " << date_string
292            << " not in YYYY-MM-DDTHH:MM:SS format; skipped");
293     return;
294   }
295
296                                 // OK, it looks like we got six
297                                 // values, one way or another.
298   new_time.tm_year -= 1900;
299   new_time.tm_mon -= 1;
300
301                                 // Now, tell flight gear to use
302                                 // the new time.  This was far
303                                 // too difficult, by the way.
304   long int warp =
305     mktime(&new_time) - mktime(current_time) + globals->get_warp();
306   double lon = current_aircraft.fdm_state->get_Longitude();
307   double lat = current_aircraft.fdm_state->get_Latitude();
308   globals->set_warp(warp);
309   st->update(lon, lat, cur_time_override->getLongValue(), warp);
310 }
311
312 /**
313  * Return the GMT as a string.
314  */
315 static const char *
316 getGMTString ()
317 {
318   static char buf[16];
319   struct tm *t = globals->get_time_params()->getGmt();
320   snprintf(buf, 16, "%.2d:%.2d:%.2d",
321       t->tm_hour, t->tm_min, t->tm_sec);
322   return buf;
323 }
324
325 /**
326  * Return the magnetic variation
327  */
328 static double
329 getMagVar ()
330 {
331   return globals->get_mag()->get_magvar() * SGD_RADIANS_TO_DEGREES;
332 }
333
334
335 /**
336  * Return the magnetic dip
337  */
338 static double
339 getMagDip ()
340 {
341   return globals->get_mag()->get_magdip() * SGD_RADIANS_TO_DEGREES;
342 }
343
344
345 /**
346  * Return the current heading in degrees.
347  */
348 static double
349 getHeadingMag ()
350 {
351   double magheading;
352   magheading = current_aircraft.fdm_state->get_Psi() * SGD_RADIANS_TO_DEGREES - getMagVar();
353   if (magheading < 0) magheading += 360;
354   return magheading;
355 }
356
357 static long
358 getWarp ()
359 {
360   return globals->get_warp();
361 }
362
363 static void
364 setWarp (long warp)
365 {
366   globals->set_warp(warp);
367 }
368
369 static long
370 getWarpDelta ()
371 {
372   return globals->get_warp_delta();
373 }
374
375 static void
376 setWarpDelta (long delta)
377 {
378   globals->set_warp_delta(delta);
379 }
380
381 static bool
382 getWindingCCW ()
383 {
384   return winding_ccw;
385 }
386
387 static void
388 setWindingCCW (bool state)
389 {
390   winding_ccw = state;
391   if ( winding_ccw )
392     glFrontFace ( GL_CCW );
393   else
394     glFrontFace ( GL_CW );
395 }
396
397 static bool
398 getFullScreen ()
399 {
400 #if defined(FX) && !defined(WIN32)
401   return globals->get_fullscreen();
402 #else
403   return false;
404 #endif
405 }
406
407 static void
408 setFullScreen (bool state)
409 {
410 #if defined(FX) && !defined(WIN32)
411   globals->set_fullscreen(state);
412 #  if defined(XMESA_FX_FULLSCREEN) && defined(XMESA_FX_WINDOW)
413   XMesaSetFXmode( state ? XMESA_FX_FULLSCREEN : XMESA_FX_WINDOW );
414 #  endif
415 #endif
416 }
417
418 static bool
419 getFDMDataLogging ()
420 {
421   return fdm_data_logging;
422 }
423
424 static void
425 setFDMDataLogging (bool state)
426 {
427                                 // kludge; no getter or setter available
428   if (state != fdm_data_logging) {
429     fgToggleFDMdataLogging();
430     fdm_data_logging = state;
431   }
432 }
433
434 static const char *
435 getLongitudeString ()
436 {
437   static SGConstPropertyNode_ptr n = fgGetNode("/position/longitude-deg", true);
438   static SGConstPropertyNode_ptr f = fgGetNode("/sim/lon-lat-format", true);
439   static char buf[32];
440   double d = n->getDoubleValue();
441   int format = f->getIntValue();
442   char c = d < 0.0 ? 'W' : 'E';
443
444   if (format == 0) {
445     snprintf(buf, 32, "%3.6f%c", d, c);
446
447   } else if (format == 1) {
448     // dd mm.mmm' (DMM-Format) -- uses a round-off factor tailored to the
449     // required precision of the minutes field (three decimal places),
450     // preventing minute values of 60.
451     double deg = fabs(d) + 5.0E-4 / 60.0;
452     double min = fabs(deg - int(deg)) * 60.0 - 4.999E-4;
453     snprintf(buf, 32, "%d*%06.3f%c", int(d < 0.0 ? -deg : deg), min, c);
454
455   } else {
456     // mm'ss.s'' (DMS-Format) -- uses a round-off factor tailored to the
457     // required precision of the seconds field (one decimal place),
458     // preventing second values of 60.
459     double deg = fabs(d) + 0.05 / 3600.0;
460     double min = (deg - int(deg)) * 60.0;
461     double sec = (min - int(min)) * 60.0 - 0.049;
462     snprintf(buf, 32, "%d*%02d %04.1f%c", int(d < 0.0 ? -deg : deg),
463         int(min), fabs(sec), c);
464   }
465   return buf;
466 }
467
468 static const char *
469 getLatitudeString ()
470 {
471   static SGConstPropertyNode_ptr n = fgGetNode("/position/latitude-deg", true);
472   static SGConstPropertyNode_ptr f = fgGetNode("/sim/lon-lat-format", true);
473   static char buf[32];
474   double d = n->getDoubleValue();
475   int format = f->getIntValue();
476   char c = d < 0.0 ? 'S' : 'N';
477
478   if (format == 0) {
479     snprintf(buf, 32, "%3.6f%c", d, c);
480
481   } else if (format == 1) {
482     double deg = fabs(d) + 5.0E-4 / 60.0;
483     double min = fabs(deg - int(deg)) * 60.0 - 4.999E-4;
484     snprintf(buf, 32, "%d*%06.3f%c", int(d < 0.0 ? -deg : deg), min, c);
485
486   } else {
487     double deg = fabs(d) + 0.05 / 3600.0;
488     double min = (deg - int(deg)) * 60.0;
489     double sec = (min - int(min)) * 60.0 - 0.049;
490     snprintf(buf, 32, "%d*%02d %04.1f%c", int(d < 0.0 ? -deg : deg),
491         int(min), fabs(sec), c);
492   }
493   return buf;
494 }
495
496
497
498 \f
499 ////////////////////////////////////////////////////////////////////////
500 // Tie the properties.
501 ////////////////////////////////////////////////////////////////////////
502
503 FGProperties::FGProperties ()
504 {
505 }
506
507 FGProperties::~FGProperties ()
508 {
509 }
510
511 void
512 FGProperties::init ()
513 {
514 }
515
516 void
517 FGProperties::bind ()
518 {
519                                 // Simulation
520   fgTie("/sim/logging/priority", getLoggingPriority, setLoggingPriority);
521   fgTie("/sim/logging/classes", getLoggingClasses, setLoggingClasses);
522   fgTie("/sim/freeze/master", getFreeze, setFreeze);
523
524   fgTie("/sim/time/elapsed-sec", getElapsedTime_sec);
525   fgTie("/sim/time/gmt", getDateString, setDateString);
526   fgSetArchivable("/sim/time/gmt");
527   fgTie("/sim/time/gmt-string", getGMTString);
528
529                                 // Position
530   fgTie("/position/latitude-string", getLatitudeString);
531   fgTie("/position/longitude-string", getLongitudeString);
532
533                                 // Orientation
534   fgTie("/orientation/heading-magnetic-deg", getHeadingMag);
535
536   fgTie("/environment/magnetic-variation-deg", getMagVar);
537   fgTie("/environment/magnetic-dip-deg", getMagDip);
538
539   fgTie("/sim/time/warp", getWarp, setWarp, false);
540   fgTie("/sim/time/warp-delta", getWarpDelta, setWarpDelta);
541
542                                 // Misc. Temporary junk.
543   fgTie("/sim/temp/winding-ccw", getWindingCCW, setWindingCCW, false);
544   fgTie("/sim/temp/full-screen", getFullScreen, setFullScreen);
545   fgTie("/sim/temp/fdm-data-logging", getFDMDataLogging, setFDMDataLogging);
546 }
547
548 void
549 FGProperties::unbind ()
550 {
551                                 // Simulation
552   fgUntie("/sim/logging/priority");
553   fgUntie("/sim/logging/classes");
554   fgUntie("/sim/freeze/master");
555
556   fgUntie("/sim/time/elapsed-sec");
557   fgUntie("/sim/time/gmt");
558   fgUntie("/sim/time/gmt-string");
559                                 // Position
560   fgUntie("/position/latitude-string");
561   fgUntie("/position/longitude-string");
562
563                                 // Orientation
564   fgUntie("/orientation/heading-magnetic-deg");
565
566                                 // Environment
567   fgUntie("/environment/magnetic-variation-deg");
568   fgUntie("/environment/magnetic-dip-deg");
569
570   fgUntie("/sim/time/warp");
571   fgUntie("/sim/time/warp-delta");
572
573                                 // Misc. Temporary junk.
574   fgUntie("/sim/temp/winding-ccw");
575   fgUntie("/sim/temp/full-screen");
576   fgUntie("/sim/temp/fdm-data-logging");
577 }
578
579 void
580 FGProperties::update (double dt)
581 {
582                                 // Date and time
583     struct tm *t = globals->get_time_params()->getGmt();
584
585     fgSetInt("/sim/time/utc/year", t->tm_year + 1900);
586     fgSetInt("/sim/time/utc/month", t->tm_mon + 1);
587     fgSetInt("/sim/time/utc/day", t->tm_mday);
588     fgSetInt("/sim/time/utc/hour", t->tm_hour);
589     fgSetInt("/sim/time/utc/minute", t->tm_min);
590     fgSetInt("/sim/time/utc/second", t->tm_sec);
591
592     fgSetDouble("/sim/time/utc/day-seconds",
593                 t->tm_hour * 3600 +
594                 t->tm_min * 60 +
595                 t->tm_sec);
596
597     fgSetInt("/sim/time/local-offset",
598              globals->get_time_params()->get_local_offset());
599 }
600
601
602 \f
603 ////////////////////////////////////////////////////////////////////////
604 // Save and restore.
605 ////////////////////////////////////////////////////////////////////////
606
607
608 /**
609  * Save the current state of the simulator to a stream.
610  */
611 bool
612 fgSaveFlight (ostream &output, bool write_all)
613 {
614
615   fgSetBool("/sim/presets/onground", false);
616   fgSetArchivable("/sim/presets/onground");
617   fgSetBool("/sim/presets/trim", false);
618   fgSetArchivable("/sim/presets/trim");
619   fgSetString("/sim/presets/speed-set", "UVW");
620   fgSetArchivable("/sim/presets/speed-set");
621
622   try {
623     writeProperties(output, globals->get_props(), write_all);
624   } catch (const sg_exception &e) {
625     guiErrorMessage("Error saving flight: ", e);
626     return false;
627   }
628   return true;
629 }
630
631
632 /**
633  * Restore the current state of the simulator from a stream.
634  */
635 bool
636 fgLoadFlight (istream &input)
637 {
638   SGPropertyNode props;
639   try {
640     readProperties(input, &props);
641   } catch (const sg_exception &e) {
642     guiErrorMessage("Error reading saved flight: ", e);
643     return false;
644   }
645
646   fgSetBool("/sim/presets/onground", false);
647   fgSetBool("/sim/presets/trim", false);
648   fgSetString("/sim/presets/speed-set", "UVW");
649
650   copyProperties(&props, globals->get_props());
651   // When loading a flight, make it the
652   // new initial state.
653   globals->saveInitialState();
654   return true;
655 }
656
657
658 bool
659 fgLoadProps (const char * path, SGPropertyNode * props, bool in_fg_root, int default_mode)
660 {
661     string fullpath;
662     if (in_fg_root) {
663         SGPath loadpath(globals->get_fg_root());
664         loadpath.append(path);
665         fullpath = loadpath.str();
666     } else {
667         fullpath = path;
668     }
669
670     try {
671         readProperties(fullpath, props, default_mode);
672     } catch (const sg_exception &e) {
673         guiErrorMessage("Error reading properties: ", e);
674         return false;
675     }
676     return true;
677 }
678
679
680 \f
681 ////////////////////////////////////////////////////////////////////////
682 // Property convenience functions.
683 ////////////////////////////////////////////////////////////////////////
684
685 SGPropertyNode *
686 fgGetNode (const char * path, bool create)
687 {
688   return globals->get_props()->getNode(path, create);
689 }
690
691 SGPropertyNode * 
692 fgGetNode (const char * path, int index, bool create)
693 {
694   return globals->get_props()->getNode(path, index, create);
695 }
696
697 bool
698 fgHasNode (const char * path)
699 {
700   return (fgGetNode(path, false) != 0);
701 }
702
703 void
704 fgAddChangeListener (SGPropertyChangeListener * listener, const char * path)
705 {
706   fgGetNode(path, true)->addChangeListener(listener);
707 }
708
709 void
710 fgAddChangeListener (SGPropertyChangeListener * listener,
711                      const char * path, int index)
712 {
713   fgGetNode(path, index, true)->addChangeListener(listener);
714 }
715
716 bool
717 fgGetBool (const char * name, bool defaultValue)
718 {
719   return globals->get_props()->getBoolValue(name, defaultValue);
720 }
721
722 int
723 fgGetInt (const char * name, int defaultValue)
724 {
725   return globals->get_props()->getIntValue(name, defaultValue);
726 }
727
728 int
729 fgGetLong (const char * name, long defaultValue)
730 {
731   return globals->get_props()->getLongValue(name, defaultValue);
732 }
733
734 float
735 fgGetFloat (const char * name, float defaultValue)
736 {
737   return globals->get_props()->getFloatValue(name, defaultValue);
738 }
739
740 double
741 fgGetDouble (const char * name, double defaultValue)
742 {
743   return globals->get_props()->getDoubleValue(name, defaultValue);
744 }
745
746 const char *
747 fgGetString (const char * name, const char * defaultValue)
748 {
749   return globals->get_props()->getStringValue(name, defaultValue);
750 }
751
752 bool
753 fgSetBool (const char * name, bool val)
754 {
755   return globals->get_props()->setBoolValue(name, val);
756 }
757
758 bool
759 fgSetInt (const char * name, int val)
760 {
761   return globals->get_props()->setIntValue(name, val);
762 }
763
764 bool
765 fgSetLong (const char * name, long val)
766 {
767   return globals->get_props()->setLongValue(name, val);
768 }
769
770 bool
771 fgSetFloat (const char * name, float val)
772 {
773   return globals->get_props()->setFloatValue(name, val);
774 }
775
776 bool
777 fgSetDouble (const char * name, double val)
778 {
779   return globals->get_props()->setDoubleValue(name, val);
780 }
781
782 bool
783 fgSetString (const char * name, const char * val)
784 {
785   return globals->get_props()->setStringValue(name, val);
786 }
787
788 void
789 fgSetArchivable (const char * name, bool state)
790 {
791   SGPropertyNode * node = globals->get_props()->getNode(name);
792   if (node == 0)
793     SG_LOG(SG_GENERAL, SG_DEBUG,
794            "Attempt to set archive flag for non-existant property "
795            << name);
796   else
797     node->setAttribute(SGPropertyNode::ARCHIVE, state);
798 }
799
800 void
801 fgSetReadable (const char * name, bool state)
802 {
803   SGPropertyNode * node = globals->get_props()->getNode(name);
804   if (node == 0)
805     SG_LOG(SG_GENERAL, SG_DEBUG,
806            "Attempt to set read flag for non-existant property "
807            << name);
808   else
809     node->setAttribute(SGPropertyNode::READ, state);
810 }
811
812 void
813 fgSetWritable (const char * name, bool state)
814 {
815   SGPropertyNode * node = globals->get_props()->getNode(name);
816   if (node == 0)
817     SG_LOG(SG_GENERAL, SG_DEBUG,
818            "Attempt to set write flag for non-existant property "
819            << name);
820   else
821     node->setAttribute(SGPropertyNode::WRITE, state);
822 }
823
824 void
825 fgUntie (const char * name)
826 {
827   if (!globals->get_props()->untie(name))
828     SG_LOG(SG_GENERAL, SG_WARN, "Failed to untie property " << name);
829 }
830
831
832 // end of fg_props.cxx