{ FOO_PARAM, BAR_ID, (QofAccessFunc)qofFooGetBar, (QofSetterFunc)qofFooSetBar },
This is limited as each FOO entity can contain only one reference to a single BAR entity per parameter. Also, this parameter cannot be used to link to a similar object, OBJ. This requires "one to many" links.
There are two types of one-to-many links in QOF.
Currently, there is no explicit way to support many-to-many links but existing methods can be combined to give approximately the same results.
A QOF_TYPE_CHOICE object is like a C++ template. QOF_TYPE_CHOICE doesn't really exist by itself:
QOF_TYPE_CHOICE<QOF_X, QOF_Y, QOF_Z>
Each choice type has it's own definition of the allowable objects - each of which need to be registered as normal. Objects can declare themselves to be one option of a particular choice. There is no requirement for any object to be either a choice or an option for a choice object.
Files | |
| file | qofchoice.h |
| Linking one entity to a single entity of many possible types. | |
Defines | |
| #define | QOF_TYPE_CHOICE "choice" |
| Identify an object as containing a choice. | |
Functions | |
| gboolean | qof_object_is_choice (QofIdType type) |
| Does this object contain a choice parameter? | |
| gboolean | qof_choice_create (char *type) |
| Set an object as using QOF_TYPE_CHOICE. | |
| gboolean | qof_choice_add_class (char *choice, char *add, char *param_name) |
| Add the choices for this parameter to the object. | |
| GList * | qof_object_get_choices (QofIdType type, QofParam *param) |
| Return the list of all object types usable with this parameter. | |
| gboolean | qof_choice_check (char *choice_obj, char *param_name, char *choice) |
| Is the choice valid for this param_name? | |
|
||||||||||||||||
|
Add the choices for this parameter to the object.
Definition at line 67 of file qofchoice.c. 00068 { 00069 GHashTable *param_table; 00070 GList *option_list; 00071 00072 option_list = NULL; 00073 param_table = NULL; 00074 g_return_val_if_fail(select != NULL, FALSE); 00075 g_return_val_if_fail(qof_object_is_choice(select), FALSE); 00076 param_table = (GHashTable*)g_hash_table_lookup(qof_choice_table, select); 00077 g_return_val_if_fail(param_table, FALSE); 00078 option_list = (GList*)g_hash_table_lookup(param_table, param_name); 00079 option_list = g_list_append(option_list, option); 00080 g_hash_table_insert(param_table, param_name, option_list); 00081 return TRUE; 00082 }
|
|
||||||||||||||||
|
Is the choice valid for this param_name?
Definition at line 97 of file qofchoice.c. 00098 { 00099 GList *choices, *result; 00100 GHashTable *param_table; 00101 00102 choices = result = NULL; 00103 g_return_val_if_fail(qof_object_is_choice(choice_obj), FALSE); 00104 param_table = g_hash_table_lookup(qof_choice_table, choice_obj); 00105 choices = g_hash_table_lookup(param_table, param_name); 00106 result = g_list_find(choices, choice); 00107 if(!result) { return FALSE; } 00108 return TRUE; 00109 }
|
|
||||||||||||
|
Return the list of all object types usable with this parameter.
Definition at line 84 of file qofchoice.c. 00085 { 00086 GList *choices; 00087 GHashTable *param_table; 00088 00089 g_return_val_if_fail(type != NULL, NULL); 00090 g_return_val_if_fail(qof_choice_is_initialized() == TRUE, FALSE); 00091 choices = NULL; 00092 param_table = g_hash_table_lookup(qof_choice_table, type); 00093 choices = g_hash_table_lookup(param_table, param->param_name); 00094 return choices; 00095 }
|
|
|
Does this object contain a choice parameter? Returns TRUE if any parameter in the object definition uses a choice of elements, whether or not those parameters contain any data.
Definition at line 41 of file qofchoice.c. 00042 { 00043 gpointer value, check; 00044 00045 value = NULL; 00046 check = NULL; 00047 g_return_val_if_fail(qof_choice_is_initialized(), FALSE); 00048 g_return_val_if_fail(type != NULL, FALSE); 00049 value = g_hash_table_lookup(qof_choice_table, type); 00050 if((GHashTable*)value) { return TRUE; } 00051 g_message("DEBUG: QOF_TYPE_CHOICE setup failed for %s\n", type); 00052 return FALSE; 00053 }
|
1.4.5