JSBSim Flight Dynamics Model 1.2.3 (07 Jun 2025)
An Open Source Flight Dynamics and Control Software Library in C++
Loading...
Searching...
No Matches
SGRawValueFunctionsIndexed< T > Class Template Reference

Detailed Description

template<class T>
class SGRawValueFunctionsIndexed< T >

An indexed value bound to static functions.

A read-only value will not have a setter; a write-only value will not have a getter. An indexed value is useful for binding one of a list of possible values (such as multiple engines for a plane). The index is hard-coded at creation time.

See also
SGRawValue

Definition at line 549 of file props.hxx.

#include <props.hxx>

+ Inheritance diagram for SGRawValueFunctionsIndexed< T >:
+ Collaboration diagram for SGRawValueFunctionsIndexed< T >:

Public Types

typedef T(* getter_t) (int)
 
typedef void(* setter_t) (int, T)
 

Public Member Functions

 SGRawValueFunctionsIndexed (int index, getter_t getter=0, setter_t setter=0)
 
virtual SGRawclone () const
 
virtual T getValue () const
 Return the underlying value.
 
virtual bool setValue (T value)
 Assign a new underlying value.
 
- Public Member Functions inherited from SGRawValue< T >
 SGRawValue ()
 Constructor.
 
virtual ~SGRawValue ()
 Destructor.
 
bool DefaultValue ()
 
const char * DefaultValue ()
 
virtual simgear::props::Type getType () const
 Return the type tag for this raw value type.
 

Additional Inherited Members

- Static Public Member Functions inherited from SGRawValue< T >
static T DefaultValue ()
 The default underlying value for this type.
 

Member Typedef Documentation

◆ getter_t

template<class T >
typedef T(* getter_t) (int)

Definition at line 552 of file props.hxx.

◆ setter_t

template<class T >
typedef void(* setter_t) (int, T)

Definition at line 553 of file props.hxx.

Constructor & Destructor Documentation

◆ SGRawValueFunctionsIndexed()

template<class T >
SGRawValueFunctionsIndexed ( int  index,
getter_t  getter = 0,
setter_t  setter = 0 
)
inline

Definition at line 554 of file props.hxx.

555 : _index(index), _getter(getter), _setter(setter) {}

◆ ~SGRawValueFunctionsIndexed()

template<class T >
virtual ~SGRawValueFunctionsIndexed ( )
inlinevirtual

Definition at line 556 of file props.hxx.

556{}

Member Function Documentation

◆ clone()

template<class T >
virtual SGRaw * clone ( ) const
inlinevirtual

Definition at line 565 of file props.hxx.

565 {
566 return new SGRawValueFunctionsIndexed(_index, _getter, _setter);
567 }
An indexed value bound to static functions.
Definition props.hxx:550

◆ getValue()

template<class T >
virtual T getValue ( ) const
inlinevirtual

Return the underlying value.

Returns
The actual value for the property.
See also
setValue

Implements SGRawValue< T >.

Definition at line 557 of file props.hxx.

557 {
558 if (_getter) return (*_getter)(_index);
559 else return SGRawValue<T>::DefaultValue();
560 }
static T DefaultValue()
The default underlying value for this type.
Definition props.hxx:332
+ Here is the call graph for this function:

◆ setValue()

template<class T >
virtual bool setValue ( value)
inlinevirtual

Assign a new underlying value.

If the new value cannot be set (because this is a read-only raw value, or because the new value is not acceptable for some reason) this method returns false and leaves the original value unchanged.

Parameters
valueThe actual value for the property.
Returns
true if the value was set successfully, false otherwise.
See also
getValue

Implements SGRawValue< T >.

Definition at line 561 of file props.hxx.

561 {
562 if (_setter) { (*_setter)(_index, value); return true; }
563 else return false;
564 }

The documentation for this class was generated from the following file: