]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim/FGPropertyManager.h
Converted FCS to use property tree internally, documentation updates.
[flightgear.git] / src / FDM / JSBSim / FGPropertyManager.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2  
3  Header:       FGPropertyManager.h
4  Author:       Tony Peden
5                Based on work originally by David Megginson
6  Date:         2/2002
7  
8  ------------- Copyright (C) 2002 -------------
9  
10  This program is free software; you can redistribute it and/or modify it under
11  the terms of the GNU General Public License as published by the Free Software
12  Foundation; either version 2 of the License, or (at your option) any later
13  version.
14  
15  This program is distributed in the hope that it will be useful, but WITHOUT
16  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
18  details.
19  
20  You should have received a copy of the GNU General Public License along with
21  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22  Place - Suite 330, Boston, MA  02111-1307, USA.
23
24  Further information about the GNU General Public License can also be found on
25  the world wide web at http://www.gnu.org.
26  
27 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
28 SENTRY
29 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
30
31 #ifndef FGPROPERTYMANAGER_H
32 #define FGPROPERTYMANAGER_H
33
34 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35 INCLUDES
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
37
38 #include <simgear/misc/props.hxx>
39
40 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
41 DEFINITIONS
42 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
43
44 #define ID_PROPERTYMANAGER "$Id$"
45
46 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
47 FORWARD DECLARATIONS
48 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
49
50 using namespace std;
51
52 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53 COMMENTS, REFERENCES, and NOTES [use "class documentation" below for API docs]
54 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
55
56 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57 CLASS DOCUMENTATION
58 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
59
60 /** Class wrapper for property handling.
61     @author David Megginson, Tony Peden
62     @see <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jsbsim/JSBSim/FGPropertyManager.h?rev=HEAD&content-type=text/vnd.viewcvs-markup">
63          Header File </a>
64     @see <a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/jsbsim/JSBSim/FGPropertyManager.cpp?rev=HEAD&content-type=text/vnd.viewcvs-markup">
65          Source File </a>
66   */
67   
68 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
69 CLASS DECLARATION
70 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
71
72 class FGPropertyManager:public SGPropertyNode {
73   public:
74     /// Constructor
75     FGPropertyManager(void) {
76       
77     }
78     /// Destructor
79     ~FGPropertyManager(void) {
80       
81     }   
82     /**
83      * Get a property node.
84      *
85      * @param path The path of the node, relative to root.
86      * @param create true to create the node if it doesn't exist.
87      * @return The node, or 0 if none exists and none was created.
88      */
89     inline FGPropertyManager* 
90     GetNode (const string &path, bool create = false)
91     {
92       SGPropertyNode* node=this->getNode(path.c_str(), create);
93       if(node == 0) 
94         cout << "FGPropertyManager::GetNode() No node found for " 
95              << path << endl;
96       return (FGPropertyManager*)node;
97     }
98   
99     inline FGPropertyManager* 
100     GetNode (const string &relpath, int index, bool create = false)
101     {
102         return (FGPropertyManager*)getNode(relpath.c_str(),index,create);
103     }    
104
105
106     /**
107      * Test whether a given node exists.
108      *
109      * @param path The path of the node, relative to root.
110      * @return true if the node exists, false otherwise.
111      */
112     inline bool
113     HasNode (const string &path)
114     {
115       return (GetNode(path, false) != 0);
116     }
117
118     /**
119      * Get the name of a node
120      */
121     inline string
122     GetName( void ) {
123       return string( getName() );
124     }  
125
126     /**
127      * Get a bool value for a property.
128      *
129      * This method is convenient but inefficient.  It should be used
130      * infrequently (i.e. for initializing, loading, saving, etc.),
131      * not in the main loop.  If you need to get a value frequently,
132      * it is better to look up the node itself using GetNode and then
133      * use the node's getBoolValue() method, to avoid the lookup overhead.
134      *
135      * @param name The property name.
136      * @param defaultValue The default value to return if the property
137      *        does not exist.
138      * @return The property's value as a bool, or the default value provided.
139      */
140     inline bool GetBool (const string &name, bool defaultValue = false)
141     {
142       return getBoolValue(name.c_str(), defaultValue);
143     }
144
145
146     /**
147      * Get an int value for a property.
148      *
149      * This method is convenient but inefficient.  It should be used
150      * infrequently (i.e. for initializing, loading, saving, etc.),
151      * not in the main loop.  If you need to get a value frequently,
152      * it is better to look up the node itself using GetNode and then
153      * use the node's getIntValue() method, to avoid the lookup overhead.
154      *
155      * @param name The property name.
156      * @param defaultValue The default value to return if the property
157      *        does not exist.
158      * @return The property's value as an int, or the default value provided.
159      */
160     inline int GetInt (const string &name, int defaultValue = 0)
161     {
162       return getIntValue(name.c_str(), defaultValue);
163     }
164
165
166     /**
167      * Get a long value for a property.
168      *
169      * This method is convenient but inefficient.  It should be used
170      * infrequently (i.e. for initializing, loading, saving, etc.),
171      * not in the main loop.  If you need to get a value frequently,
172      * it is better to look up the node itself using GetNode and then
173      * use the node's getLongValue() method, to avoid the lookup overhead.
174      *
175      * @param name The property name.
176      * @param defaultValue The default value to return if the property
177      *        does not exist.
178      * @return The property's value as a long, or the default value provided.
179      */
180     inline int GetLong (const string &name, long defaultValue = 0L)
181     {
182       return getLongValue(name.c_str(), defaultValue);
183     }
184
185
186     /**
187      * Get a float value for a property.
188      *
189      * This method is convenient but inefficient.  It should be used
190      * infrequently (i.e. for initializing, loading, saving, etc.),
191      * not in the main loop.  If you need to get a value frequently,
192      * it is better to look up the node itself using GetNode and then
193      * use the node's getFloatValue() method, to avoid the lookup overhead.
194      *
195      * @param name The property name.
196      * @param defaultValue The default value to return if the property
197      *        does not exist.
198      * @return The property's value as a float, or the default value provided.
199      */
200     inline float GetFloat (const string &name, float defaultValue = 0.0)
201     {
202       return getFloatValue(name.c_str(), defaultValue);
203     }
204
205
206     /**
207      * Get a double value for a property.
208      *
209      * This method is convenient but inefficient.  It should be used
210      * infrequently (i.e. for initializing, loading, saving, etc.),
211      * not in the main loop.  If you need to get a value frequently,
212      * it is better to look up the node itself using GetNode and then
213      * use the node's getDoubleValue() method, to avoid the lookup overhead.
214      *
215      * @param name The property name.
216      * @param defaultValue The default value to return if the property
217      *        does not exist.
218      * @return The property's value as a double, or the default value provided.
219      */
220     inline double GetDouble (const string &name, double defaultValue = 0.0)
221     {
222       return getDoubleValue(name.c_str(), defaultValue);
223     }
224
225
226     /**
227      * Get a string value for a property.
228      *
229      * This method is convenient but inefficient.  It should be used
230      * infrequently (i.e. for initializing, loading, saving, etc.),
231      * not in the main loop.  If you need to get a value frequently,
232      * it is better to look up the node itself using GetNode and then
233      * use the node's getStringValue() method, to avoid the lookup overhead.
234      *
235      * @param name The property name.
236      * @param defaultValue The default value to return if the property
237      *        does not exist.
238      * @return The property's value as a string, or the default value provided.
239      */
240     inline string GetString (const string &name, string defaultValue = "")
241     {
242       return string(getStringValue(name.c_str(), defaultValue.c_str()));
243     }
244
245
246     /**
247      * Set a bool value for a property.
248      *
249      * Assign a bool value to a property.  If the property does not
250      * yet exist, it will be created and its type will be set to
251      * BOOL; if it has a type of UNKNOWN, the type will also be set to
252      * BOOL; otherwise, the bool value will be converted to the property's
253      * type.
254      *
255      * @param name The property name.
256      * @param val The new value for the property.
257      * @return true if the assignment succeeded, false otherwise.
258      */
259     inline bool SetBool (const string &name, bool val)
260     {
261       return setBoolValue(name.c_str(), val);
262     }
263
264
265     /**
266      * Set an int value for a property.
267      *
268      * Assign an int value to a property.  If the property does not
269      * yet exist, it will be created and its type will be set to
270      * INT; if it has a type of UNKNOWN, the type will also be set to
271      * INT; otherwise, the bool value will be converted to the property's
272      * type.
273      *
274      * @param name The property name.
275      * @param val The new value for the property.
276      * @return true if the assignment succeeded, false otherwise.
277      */
278     inline bool SetInt (const string &name, int val)
279     {
280       return setIntValue(name.c_str(), val);
281     }
282
283
284     /**
285      * Set a long value for a property.
286      *
287      * Assign a long value to a property.  If the property does not
288      * yet exist, it will be created and its type will be set to
289      * LONG; if it has a type of UNKNOWN, the type will also be set to
290      * LONG; otherwise, the bool value will be converted to the property's
291      * type.
292      *
293      * @param name The property name.
294      * @param val The new value for the property.
295      * @return true if the assignment succeeded, false otherwise.
296      */
297     inline bool SetLong (const string &name, long val)
298     {
299       return setLongValue(name.c_str(), val);
300     }
301
302
303     /**
304      * Set a float value for a property.
305      *
306      * Assign a float value to a property.  If the property does not
307      * yet exist, it will be created and its type will be set to
308      * FLOAT; if it has a type of UNKNOWN, the type will also be set to
309      * FLOAT; otherwise, the bool value will be converted to the property's
310      * type.
311      *
312      * @param name The property name.
313      * @param val The new value for the property.
314      * @return true if the assignment succeeded, false otherwise.
315      */
316     inline bool SetFloat (const string &name, float val)
317     {
318       return setFloatValue(name.c_str(), val);
319     }
320
321
322     /**
323      * Set a double value for a property.
324      *
325      * Assign a double value to a property.  If the property does not
326      * yet exist, it will be created and its type will be set to
327      * DOUBLE; if it has a type of UNKNOWN, the type will also be set to
328      * DOUBLE; otherwise, the double value will be converted to the property's
329      * type.
330      *
331      * @param name The property name.
332      * @param val The new value for the property.
333      * @return true if the assignment succeeded, false otherwise.
334      */
335     inline bool SetDouble (const string &name, double val)
336     {
337       return setDoubleValue(name.c_str(), val);
338     }
339
340
341     /**
342      * Set a string value for a property.
343      *
344      * Assign a string value to a property.  If the property does not
345      * yet exist, it will be created and its type will be set to
346      * STRING; if it has a type of UNKNOWN, the type will also be set to
347      * STRING; otherwise, the string value will be converted to the property's
348      * type.
349      *
350      * @param name The property name.
351      * @param val The new value for the property.
352      * @return true if the assignment succeeded, false otherwise.
353      */
354     inline bool SetString (const string &name, const string &val)
355     {
356       return setStringValue(name.c_str(), val.c_str());
357     }
358
359
360     \f
361     ////////////////////////////////////////////////////////////////////////
362     // Convenience functions for setting property attributes.
363     ////////////////////////////////////////////////////////////////////////
364
365
366     /**
367      * Set the state of the archive attribute for a property.
368      *
369      * If the archive attribute is true, the property will be written
370      * when a flight is saved; if it is false, the property will be
371      * skipped.
372      *
373      * A warning message will be printed if the property does not exist.
374      *
375      * @param name The property name.
376      * @param state The state of the archive attribute (defaults to true).
377      */
378     inline void
379     SetArchivable (const string &name, bool state = true)
380     {
381       SGPropertyNode * node = getNode(name.c_str());
382       if (node == 0)
383         cout <<
384                "Attempt to set archive flag for non-existant property "
385                << name;
386       else
387         node->setAttribute(SGPropertyNode::ARCHIVE, state);
388     }
389
390
391     /**
392      * Set the state of the read attribute for a property.
393      *
394      * If the read attribute is true, the property value will be readable;
395      * if it is false, the property value will always be the default value
396      * for its type.
397      *
398      * A warning message will be printed if the property does not exist.
399      *
400      * @param name The property name.
401      * @param state The state of the read attribute (defaults to true).
402      */
403     inline void
404     SetReadable (const string &name, bool state = true)
405     {
406       SGPropertyNode * node = getNode(name.c_str());
407       if (node == 0)
408         cout <<
409                "Attempt to set read flag for non-existant property "
410                << name;
411       else
412         node->setAttribute(SGPropertyNode::READ, state);
413     }
414
415
416     /**
417      * Set the state of the write attribute for a property.
418      *
419      * If the write attribute is true, the property value may be modified
420      * (depending on how it is tied); if the write attribute is false, the
421      * property value may not be modified.
422      *
423      * A warning message will be printed if the property does not exist.
424      *
425      * @param name The property name.
426      * @param state The state of the write attribute (defaults to true).
427      */
428     inline void
429     SetWritable (const string &name, bool state = true)
430     {
431       SGPropertyNode * node = getNode(name.c_str());
432       if (node == 0)
433         cout <<
434                "Attempt to set write flag for non-existant property "
435                << name;
436       else
437         node->setAttribute(SGPropertyNode::WRITE, state);
438     }
439
440
441     \f
442     ////////////////////////////////////////////////////////////////////////
443     // Convenience functions for tying properties, with logging.
444     ////////////////////////////////////////////////////////////////////////
445
446
447     /**
448      * Untie a property from an external data source.
449      *
450      * Classes should use this function to release control of any
451      * properties they are managing.
452      */
453     inline void
454     Untie (const string &name)
455     {
456       if (!untie(name.c_str()))
457         cout << "Failed to untie property " << name;
458     }
459
460
461                                     // Templates cause ambiguity here
462
463     /**
464      * Tie a property to an external bool variable.
465      *
466      * The property's value will automatically mirror the variable's
467      * value, and vice-versa, until the property is untied.
468      *
469      * @param name The property name to tie (full path).
470      * @param pointer A pointer to the variable.
471      * @param useDefault true if any existing property value should be
472      *        copied to the variable; false if the variable should not
473      *        be modified; defaults to true.
474      */
475     inline void
476     Tie (const string &name, bool *pointer, bool useDefault = true)
477     {
478       if (!tie(name.c_str(), SGRawValuePointer<bool>(pointer),
479                                      useDefault))
480         cout <<
481                "Failed to tie property " << name << " to a pointer";
482     }
483
484
485     /**
486      * Tie a property to an external int variable.
487      *
488      * The property's value will automatically mirror the variable's
489      * value, and vice-versa, until the property is untied.
490      *
491      * @param name The property name to tie (full path).
492      * @param pointer A pointer to the variable.
493      * @param useDefault true if any existing property value should be
494      *        copied to the variable; false if the variable should not
495      *        be modified; defaults to true.
496      */
497     inline void
498     Tie (const string &name, int *pointer, bool useDefault = true)
499     {
500       if (!tie(name.c_str(), SGRawValuePointer<int>(pointer),
501                                      useDefault))
502         cout <<
503                "Failed to tie property " << name << " to a pointer";
504     }
505
506
507     /**
508      * Tie a property to an external long variable.
509      *
510      * The property's value will automatically mirror the variable's
511      * value, and vice-versa, until the property is untied.
512      *
513      * @param name The property name to tie (full path).
514      * @param pointer A pointer to the variable.
515      * @param useDefault true if any existing property value should be
516      *        copied to the variable; false if the variable should not
517      *        be modified; defaults to true.
518      */
519     inline void
520     Tie (const string &name, long *pointer, bool useDefault = true)
521     {
522       if (!tie(name.c_str(), SGRawValuePointer<long>(pointer),
523                                      useDefault))
524         cout <<
525                "Failed to tie property " << name << " to a pointer";
526     }
527
528
529     /**
530      * Tie a property to an external float variable.
531      *
532      * The property's value will automatically mirror the variable's
533      * value, and vice-versa, until the property is untied.
534      *
535      * @param name The property name to tie (full path).
536      * @param pointer A pointer to the variable.
537      * @param useDefault true if any existing property value should be
538      *        copied to the variable; false if the variable should not
539      *        be modified; defaults to true.
540      */
541     inline void
542     Tie (const string &name, float *pointer, bool useDefault = true)
543     {
544       if (!tie(name.c_str(), SGRawValuePointer<float>(pointer),
545                                      useDefault))
546         cout <<
547                "Failed to tie property " << name << " to a pointer";
548     }
549
550
551     /**
552      * Tie a property to an external double variable.
553      *
554      * The property's value will automatically mirror the variable's
555      * value, and vice-versa, until the property is untied.
556      *
557      * @param name The property name to tie (full path).
558      * @param pointer A pointer to the variable.
559      * @param useDefault true if any existing property value should be
560      *        copied to the variable; false if the variable should not
561      *        be modified; defaults to true.
562      */
563     inline void
564     Tie (const string &name, double *pointer, bool useDefault = true)
565     {
566       if (!tie(name.c_str(), SGRawValuePointer<double>(pointer),
567                                      useDefault))
568         cout <<
569                "Failed to tie property " << name << " to a pointer";
570     }
571
572     /* template <class V> void
573     Tie (const string &name, V (*getter)(), void (*setter)(V) = 0,
574            bool useDefault = true);
575     
576     template <class V> void
577     Tie (const string &name, int index, V (*getter)(int),
578            void (*setter)(int, V) = 0, bool useDefault = true);
579     
580     template <class T, class V> void
581     Tie (const string &name, T * obj, V (T::*getter)() const,
582            void (T::*setter)(V) = 0, bool useDefault = true);
583
584     template <class T, class V> void 
585     Tie (const string &name, T * obj, int index,
586            V (T::*getter)(int) const, void (T::*setter)(int, V) = 0,
587            bool useDefault = true); */
588
589 /**
590      * Tie a property to a pair of simple functions.
591      *
592      * Every time the property value is queried, the getter (if any) will
593      * be invoked; every time the property value is modified, the setter
594      * (if any) will be invoked.  The getter can be 0 to make the property
595      * unreadable, and the setter can be 0 to make the property
596      * unmodifiable.
597      *
598      * @param name The property name to tie (full path).
599      * @param getter The getter function, or 0 if the value is unreadable.
600      * @param setter The setter function, or 0 if the value is unmodifiable.
601      * @param useDefault true if the setter should be invoked with any existing 
602      *        property value should be; false if the old value should be
603      *        discarded; defaults to true.
604      */
605     template <class V>
606     inline void
607     Tie (const string &name, V (*getter)(), void (*setter)(V) = 0,
608            bool useDefault = true)
609     {
610       if (!tie(name.c_str(), SGRawValueFunctions<V>(getter, setter),
611                                      useDefault))
612         cout <<
613                "Failed to tie property " << name << " to functions";
614     }
615
616
617     /**
618      * Tie a property to a pair of indexed functions.
619      *
620      * Every time the property value is queried, the getter (if any) will
621      * be invoked with the index provided; every time the property value
622      * is modified, the setter (if any) will be invoked with the index
623      * provided.  The getter can be 0 to make the property unreadable, and
624      * the setter can be 0 to make the property unmodifiable.
625      *
626      * @param name The property name to tie (full path).
627      * @param index The integer argument to pass to the getter and
628      *        setter functions.
629      * @param getter The getter function, or 0 if the value is unreadable.
630      * @param setter The setter function, or 0 if the value is unmodifiable.
631      * @param useDefault true if the setter should be invoked with any existing 
632      *        property value should be; false if the old value should be
633      *        discarded; defaults to true.
634      */
635     template <class V>
636     inline void
637     Tie (const string &name, int index, V (*getter)(int),
638            void (*setter)(int, V) = 0, bool useDefault = true)
639     {
640       if (!tie(name.c_str(),
641                                      SGRawValueFunctionsIndexed<V>(index,
642                                                                    getter,
643                                                                    setter),
644                                      useDefault))
645         cout <<
646                "Failed to tie property " << name << " to indexed functions";
647     }
648
649
650     /**
651      * Tie a property to a pair of object methods.
652      *
653      * Every time the property value is queried, the getter (if any) will
654      * be invoked; every time the property value is modified, the setter
655      * (if any) will be invoked.  The getter can be 0 to make the property
656      * unreadable, and the setter can be 0 to make the property
657      * unmodifiable.
658      *
659      * @param name The property name to tie (full path).
660      * @param obj The object whose methods should be invoked.
661      * @param getter The object's getter method, or 0 if the value is
662      *        unreadable.
663      * @param setter The object's setter method, or 0 if the value is
664      *        unmodifiable.
665      * @param useDefault true if the setter should be invoked with any existing 
666      *        property value should be; false if the old value should be
667      *        discarded; defaults to true.
668      */
669     template <class T, class V>
670     inline void
671     Tie (const string &name, T * obj, V (T::*getter)() const,
672            void (T::*setter)(V) = 0, bool useDefault = true)
673     {
674       if (!tie(name.c_str(),
675                                      SGRawValueMethods<T,V>(*obj, getter, setter),
676                                      useDefault))
677         cout <<
678                "Failed to tie property " << name << " to object methods";
679     }
680
681
682     /**
683      * Tie a property to a pair of indexed object methods.
684      *
685      * Every time the property value is queried, the getter (if any) will
686      * be invoked with the index provided; every time the property value
687      * is modified, the setter (if any) will be invoked with the index
688      * provided.  The getter can be 0 to make the property unreadable, and
689      * the setter can be 0 to make the property unmodifiable.
690      *
691      * @param name The property name to tie (full path).
692      * @param obj The object whose methods should be invoked.
693      * @param index The integer argument to pass to the getter and
694      *        setter methods.
695      * @param getter The getter method, or 0 if the value is unreadable.
696      * @param setter The setter method, or 0 if the value is unmodifiable.
697      * @param useDefault true if the setter should be invoked with any existing 
698      *        property value should be; false if the old value should be
699      *        discarded; defaults to true.
700      */
701     template <class T, class V>
702     inline void 
703     Tie (const string &name, T * obj, int index,
704            V (T::*getter)(int) const, void (T::*setter)(int, V) = 0,
705            bool useDefault = true)
706     {
707       if (!tie(name.c_str(),
708                                      SGRawValueMethodsIndexed<T,V>(*obj,
709                                                                    index,
710                                                                    getter,
711                                                                    setter),
712                                      useDefault))
713         cout <<
714                "Failed to tie property " << name << " to indexed object methods";
715     }
716
717 };        
718
719
720 #endif // FGPROPERTYMANAGER_H
721