22 #ifndef _LV_PARAM_VALUE_H
23 #define _LV_PARAM_VALUE_H
25 #include <libvisual/lvconfig.h>
26 #include <libvisual/lv_types.h>
27 #include <libvisual/lv_checks.h>
28 #include <libvisual/lv_color.h>
29 #include <libvisual/lv_palette.h>
31 #define VISUAL_PARAM_VALUE(obj) ((VisParamValue *) (obj))
36 VISUAL_PARAM_TYPE_NONE,
37 VISUAL_PARAM_TYPE_BOOL,
38 VISUAL_PARAM_TYPE_INTEGER,
39 VISUAL_PARAM_TYPE_FLOAT,
40 VISUAL_PARAM_TYPE_DOUBLE,
41 VISUAL_PARAM_TYPE_COLOR,
42 VISUAL_PARAM_TYPE_STRING,
43 VISUAL_PARAM_TYPE_PALETTE,
62 LV_API VisParamValue *visual_param_value_new (VisParamType type,
void *value);
63 LV_API
void visual_param_value_init (VisParamValue *
self, VisParamType type,
void *value);
64 LV_API
void visual_param_value_copy (VisParamValue *value, VisParamValue *src);
65 LV_API
void visual_param_value_set (VisParamValue *value, VisParamType type,
void *new_value);
66 LV_API
int visual_param_value_compare (VisParamValue *lhs, VisParamValue *rhs);
67 LV_API
void visual_param_value_free (VisParamValue *value);
68 LV_API
void visual_param_value_free_value (VisParamValue *value);
70 #define _LV_PARAM_MARSHAL_INTEGER(x) ((void *) (intptr_t) (x))
71 #define _LV_PARAM_MARSHAL_FLOAT(x) ((void *) (&x))
72 #define _LV_PARAM_MARSHAL_DOUBLE(x) ((void *) (&x))
73 #define _LV_PARAM_MARSHAL_POINTER(x) ((void *) (x))
75 #define _LV_DEFINE_PARAM_VALUE_SET(func,ctype,name,marshal) \
76 static inline void visual_param_value_set_##func (VisParamValue *self, ctype value) { \
77 visual_return_if_fail (self != NULL); \
78 visual_param_value_set (self, VISUAL_PARAM_TYPE_##name, _LV_PARAM_MARSHAL_##marshal (value)); \
81 _LV_DEFINE_PARAM_VALUE_SET(
bool ,
int , BOOL , INTEGER)
82 _LV_DEFINE_PARAM_VALUE_SET(integer,
int , INTEGER, INTEGER)
83 _LV_DEFINE_PARAM_VALUE_SET(
float ,
float , FLOAT , FLOAT)
84 _LV_DEFINE_PARAM_VALUE_SET(
double ,
double , DOUBLE , DOUBLE)
85 _LV_DEFINE_PARAM_VALUE_SET(
string , const
char * , STRING , POINTER)
86 _LV_DEFINE_PARAM_VALUE_SET(color , const
VisColor * , COLOR , POINTER)
87 _LV_DEFINE_PARAM_VALUE_SET(palette, const
VisPalette *, PALETTE, POINTER)
89 #define _LV_DEFINE_PARAM_VALUE_GET(func,ctype,name,member,defvalue) \
90 static inline ctype visual_param_value_get_##func (VisParamValue *self) { \
91 visual_return_val_if_fail (self != NULL, 0); \
92 visual_return_val_if_fail (self->type == VISUAL_PARAM_TYPE_##name, defvalue); \
93 return self->value.member; \
96 _LV_DEFINE_PARAM_VALUE_GET(
bool ,
int , BOOL , integer , FALSE)
97 _LV_DEFINE_PARAM_VALUE_GET(integer,
int , INTEGER, integer , 0)
98 _LV_DEFINE_PARAM_VALUE_GET(
float ,
float , FLOAT , single_float, 0.0f)
99 _LV_DEFINE_PARAM_VALUE_GET(
double ,
double , DOUBLE , double_float, 0.0)
100 _LV_DEFINE_PARAM_VALUE_GET(
string , const
char *, STRING ,
string , NULL)
101 _LV_DEFINE_PARAM_VALUE_GET(color , VisColor * , COLOR , color , NULL)
102 _LV_DEFINE_PARAM_VALUE_GET(palette, VisPalette *, PALETTE, palette , NULL)