## SwamiParam SwamiParam |

## Synopsis

    void                (*SwamiValueTransform)              (const GValue *src,
                                                             GValue *dest,
                                                             gpointer user_data);
    gboolean            swami_param_get_limits              (GParamSpec *pspec,
                                                             gdouble *min,
                                                             gdouble *max,
                                                             gdouble *def,
                                                             gboolean *integer);
    gboolean            swami_param_set_limits              (GParamSpec *pspec,
                                                             gdouble min,
                                                             gdouble max,
                                                             gdouble def);
    gboolean            swami_param_type_has_limits         (GType param_type);
    gboolean            swami_param_convert                 (GParamSpec *dest,
                                                             GParamSpec *src);
    GParamSpec *        swami_param_convert_new             (GParamSpec *pspec,
                                                             GType value_type);
    gboolean            swami_param_type_transformable      (GType src_type,
                                                             GType dest_type);
    gboolean            swami_param_type_transformable_value
                                                            (GType src_valtype,
                                                             GType dest_valtype);
    gboolean            swami_param_transform               (GParamSpec *dest,
                                                             GParamSpec *src,
                                                             SwamiValueTransform trans,
                                                             gpointer user_data);
    GParamSpec *        swami_param_transform_new           (GParamSpec *dest,
                                                             GType value_type,
                                                             SwamiValueTransform trans,
                                                             gpointer user_data);
    GType               swami_param_type_from_value_type    (GType value_type);

## Description

## Details

### SwamiValueTransform ()

    void                (*SwamiValueTransform)              (const GValue *src,
                                                             GValue *dest,
                                                             gpointer user_data);

Prototype for value transform function. The transform function should handle any value conversions required.

`src` : | Source value to transform from
`dest` : | Destination value to store to
`user_data` : | User defined data (set when transform was connected for example)

### swami_param_get_limits ()

    gboolean            swami_param_get_limits              (GParamSpec *pspec,
                                                             gdouble *min,
                                                             gdouble *max,
                                                             gdouble *def,
                                                             gboolean *integer);

Get limits of a numeric parameter specification.

`pspec` : | GParamSpec to get limits of
`min` : | Output: Minimum value of parameter specification
`max` : | Output: Maximum value of parameter specification
`def` : | Output: Default value of parameter specification
`integer` : | Output: `TRUE` if integer parameter spec, `FALSE` if floating point
Returns : | `TRUE` if `pspec` is numeric, `FALSE` otherwise (in which case output variables are undefined)

### swami_param_set_limits ()

    gboolean            swami_param_set_limits              (GParamSpec *pspec,
                                                             gdouble min,
                                                             gdouble max,
                                                             gdouble def);

Set limits of a numeric parameter specification.

`pspec` : | GParamSpec to set limits of
`min` : | Minimum value of parameter specification
`max` : | Maximum value of parameter specification
`def` : | Default value of parameter specification
Returns : | `TRUE` if `pspec` is numeric, `FALSE` otherwise (in which case `pspec` is unchanged)

### swami_param_type_has_limits ()

    gboolean            swami_param_type_has_limits         (GType param_type);

Check if a given GParamSpec type can be used with `swami_param_get_limits()` and `swami_param_set_limits()`.

`param_type` : | GParamSpec type
Returns : | `TRUE` if can get/set limits, `FALSE` otherwise

### swami_param_convert ()

    gboolean            swami_param_convert                 (GParamSpec *dest,
                                                             GParamSpec *src);

Convert parameter limits between two numeric parameter specifications, also copies the "unit-type" and "float-digit" parameter properties. Sets "float-digits" to 0 on the `dest` parameter spec if the source is an integer type.

`src` : | Source param specification to get limits from
`dest` : | Destination param specification to set limits of
Returns : | `TRUE` if both parameter specs are numeric, `FALSE` otherwise (in which case `dest` will be unchanged).

### swami_param_convert_new ()

    GParamSpec *        swami_param_convert_new             (GParamSpec *pspec,
                                                             GType value_type);

Create a new parameter spec using values of `value_type` and convert `pspec` to the new parameter spec.

`pspec` : | Source parameter spec to convert
`value_type` : | Value type of new parameter spec
Returns : | New parameter spec that uses `value_type` or `NULL` on error (unable to convert `pspec` to `value_type`)

### swami_param_type_transformable ()

    gboolean            swami_param_type_transformable      (GType src_type,
                                                             GType dest_type);

Check if a source GParamSpec type is transformable to a destination type.

`src_type` : | Source GParamSpec type.
`dest_type` : | Destination GParamSpec type.
Returns : | `TRUE` on success, `FALSE` otherwise

### swami_param_type_transformable_value ()

    gboolean            swami_param_type_transformable_value
                                                            (GType src_valtype,
                                                             GType dest_valtype);

Check if a source GParamSpec type is transformable to a destination type by corresponding GValue types.

`src_type` : | Source GValue type.
`dest_type` : | Destination GValue type.
Returns : | `TRUE` on success, `FALSE` otherwise

### swami_param_transform ()

    gboolean            swami_param_transform               (GParamSpec *dest,
                                                             GParamSpec *src,
                                                             SwamiValueTransform trans,
                                                             gpointer user_data);

Convert parameter limits between two numeric parameter specifications using a custom transform function. The `trans` parameter specifies the transform function which is called for the min, max and default values of the `src` parameter spec, which are then assigned to `dest`. The source and destination GValue parameters to the transform function are of G_TYPE_DOUBLE.

`src` : | Source param specification to get limits from
`dest` : | Destination param specification to set limits of
`trans` : | Transform function
`user_data` : | User defined data passed to transform function
Returns : | `TRUE` if both parameter specs are numeric, `FALSE` otherwise (in which case `dest` will be unchanged).

### swami_param_transform_new ()

    GParamSpec *        swami_param_transform_new           (GParamSpec *dest,
                                                             GType value_type,
                                                             SwamiValueTransform trans,
                                                             gpointer user_data);

Create a new parameter spec using values of `value_type` and transform `pspec` to the new parameter spec using a custom transform function. See `swami_param_transform()` for more details.

`pspec` : | Source parameter spec to convert
`value_type` : | Value type of new parameter spec
`trans` : | Transform function
`user_data` : | User defined data passed to transform function
Returns : | New parameter spec that uses `value_type` or `NULL` on error (error message is then printed)

### swami_param_type_from_value_type ()

    GType               swami_param_type_from_value_type    (GType value_type);

Get a parameter spec type for a given value type.

`value_type` : | A value type to get the parameter spec type that contains it.
Returns : | Parameter spec type or 0 if no param spec type for `value_type`.