comparison src/paranormal/actuators.h @ 149:fd9c0a5871ac trunk

[svn] - new and IMPROVED paranormal visualization studio
author nenolod
date Mon, 30 Oct 2006 23:02:33 -0800
parents
children adf9f4b26039
comparison
equal deleted inserted replaced
148:9d9fc9e1de48 149:fd9c0a5871ac
1 /* FIXME: rename actuators to pn_actuators */
2 /* FIXME: add a color type to the OPT_TYPE's */
3
4 #ifndef _ACTUATORS_H
5 #define _ACTUATORS_H
6
7 #include <glib.h>
8 #include <SDL.h>
9
10 /* Helper macros for actuator functions */
11 #define PN_ACTUATOR_INIT_FUNC(f) ((void (*) (gpointer *data))f)
12 #define PN_ACTUATOR_CLEANUP_FUNC(f) ((void (*) (gpointer data))f)
13 #define PN_ACTUATOR_EXEC_FUNC(f) \
14 ((void (*) (const struct pn_actuator_option *opts, gpointer data))f)
15
16 struct pn_color
17 {
18 guchar r, g, b;
19 guchar spluzz; /* gotta look like an SDL_Color */
20 };
21
22
23 union actuator_option_val
24 {
25 int ival;
26 float fval;
27 const char *sval;
28 struct pn_color cval;
29 gboolean bval;
30 };
31
32 /* A actuator's option description */
33 struct pn_actuator_option_desc
34 {
35 const char *name;
36 const char *doc; /* option documentation */
37 enum
38 {
39 OPT_TYPE_INT = 0,
40 OPT_TYPE_FLOAT = 1,
41 OPT_TYPE_STRING = 2,
42 OPT_TYPE_COLOR = 3,
43 OPT_TYPE_COLOR_INDEX = 4, /* uses ival */
44 OPT_TYPE_BOOLEAN = 5
45 } type;
46 union actuator_option_val default_val;
47 };
48
49 /* The actual option instance */
50 struct pn_actuator_option
51 {
52 const struct pn_actuator_option_desc *desc;
53 union actuator_option_val val;
54 };
55
56 /* An operation's description */
57 struct pn_actuator_desc
58 {
59 const char *name;
60 const char *doc; /* documentation txt */
61 const enum
62 {
63 ACTUATOR_FLAG_CONTAINER = 1<<0
64 } flags;
65
66 /* A null terminating (ie a actuator_option_desc == {0,...,0})
67 array - OPTIONAL (optional fields can be NULL) */
68 const struct pn_actuator_option_desc *option_descs;
69
70 /* Init function - data points to the actuator.data - OPTIONAL */
71 void (*init) (gpointer *data);
72
73 /* Cleanup actuatortion - OPTIONAL */
74 void (*cleanup) (gpointer data);
75
76 /* Execute actuatortion - REQUIRED (duh!) */
77 void (*exec) (const struct pn_actuator_option *opts, gpointer data);
78 };
79
80 /* An actual operation instance */
81 struct pn_actuator
82 {
83 const struct pn_actuator_desc *desc;
84 struct pn_actuator_option *options;
85 gpointer data;
86 };
87
88 /* The array containing all operations (see builtins.c) */
89 extern struct pn_actuator_desc *builtin_table[];
90
91 /* functions for actuators */
92 struct pn_actuator_desc *get_actuator_desc (const char *name);
93 struct pn_actuator *copy_actuator (const struct pn_actuator *a);
94 struct pn_actuator *create_actuator (const char *name);
95 void destroy_actuator (struct pn_actuator *actuator);
96 void exec_actuator (struct pn_actuator *actuator);
97
98 #endif /* _ACTUATORS_H */