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