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