ITK Function Reference

(V10000.1.0.60_20160308.00)
Data Fields
TC_argument_list_s Struct Reference

#include <tc_arguments.h>

Data Fields

TC_argument_targuments
 
int i
 
int number_of_arguments
 

Detailed Description

List of TC_argument_t.
Before each use, the cursor to access members of the list needs to be initialized using the TC_init_argument_list method.

Below is an example. Let us create a registration method:

extern void GTAC_register_method(tag_t iPOMTag,
unsigned int iNbOfProperties, const char** iPropertyNames)
{
fprintf(stdout, "GTAC_register_method...\n");
if( iNbOfProperties>0 && !iPropertyNames )
{
fprintf(stdout, "Error %d - METHOD_find_method\n", returned);
}
int returned = ITK_ok;
METHOD_id_t method;
returned = METHOD_find_method("Item", ITEM_create_msg, &method);
if (returned) fprintf(stdout, "Error %d - METHOD_find_method\n", returned);
if (method.id != NULLTAG)
{
TC_argument_list_t *userArgs = NULL;
int number_of_arguments = iNbOfProperties + 1;
userArgs = (TC_argument_list_t *) MEM_alloc( sizeof(TC_argument_list_t) );
userArgs->number_of_arguments = 4;
userArgs->arguments = (TC_argument_t *)
int argNb=0;
userArgs->arguments[argNb].type = POM_int;
userArgs->arguments[argNb].array_size = 1;
userArgs->arguments[argNb++].val_union.int_value = iPOMTag;
for(int i=0; i<iNbOfProperties; i++)
{
userArgs->arguments[argNb].type = POM_string;
userArgs->arguments[argNb].array_size = 1;
userArgs->arguments[argNb].val_union.str_value =
(char*) MEM_alloc( tc_strlen(iPropertyNames[i])*sizeof(char) );
tc_strcpy(userArgs->arguments[argNb].val_union.str_value, iPropertyNames[i]);
argNb++;
}
GTAC_post_action, userArgs);
if (returned != ITK_ok)
fprintf(stdout, "Error %d - METHOD_add_action\n", returned);
else
fprintf(stdout, "Method post action registered\n");
}
else fprintf(stdout, "Method NOT found!\n", returned);
return returned;
}

And the registered post action method can use the argument list as follows:

extern int GTAC_post_action(METHOD_message_t *m, va_list args)
{
fprintf(stdout, "GTAC_post_action...\n");
int n_args = 0;
TC_init_argument_list(m->userArgs);
n_args = TC_number_of_arguments(m->userArgs);
fprintf(stdout, "n_args = %d\n", n_args);
for(int i=0; i<=n_args; i++)
{
if(POM_string == m->userArgs[i].type)
{
int int_val = TC_next_int_argument(m->userArgs);
fprintf(stdout, "int_val = %d\n", int_val);
}
else
{
char* str_value = TC_next_argument(m->userArgs);
fprintf(stdout, "str_value = %s\n", str_value);
}
}
return ITK_ok;
}

Definition at line 135 of file tc_arguments.h.

Field Documentation

TC_argument_t* TC_argument_list_s::arguments

Definition at line 139 of file tc_arguments.h.

int TC_argument_list_s::i

Definition at line 137 of file tc_arguments.h.

int TC_argument_list_s::number_of_arguments

Definition at line 138 of file tc_arguments.h.


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