ITK Function Reference

(V10000.1.0.60_20160308.00)
Data Structures | Macros | Typedefs | Enumerations
Teamcenter Arguments

Data Structures

struct  TC_argument_list_s
 
struct  TC_argument_s
 

Macros

#define TC_init_argument_list(a)   { if(a != 0) a->i = 0; }
 
#define TC_next_argument(a)   ((a == 0) ? 0 : ((a->i < a->number_of_arguments) ? (a->arguments[a->i++].val_union.str_value) : 0))
 
#define TC_next_int_argument(a)   ((a == 0) ? 0 : ((a->i < a->number_of_arguments) ? (a->arguments[a->i++].val_union.int_value) : 0))
 
#define TC_number_of_arguments(a)   ((a == 0) ? 0 : a->number_of_arguments)
 

Typedefs

typedef struct TC_argument_list_s TC_argument_list_t
 
typedef struct TC_argument_s TC_argument_t
 
typedef enum TC_module_state_e TC_module_state_t
 

Enumerations

enum  TC_module_state_e { TC_uninitialized, TC_initializing, TC_initialized }
 

Detailed Description

Macro Definition Documentation

#define TC_init_argument_list (   a)    { if(a != 0) a->i = 0; }

Initializes cursor position of a pointer to TC_argument_list_t.
This has to be used to ensure proper functioning of TC_next_argument and TC_next_int_argument.

Parameters
a(I) TC_argument_list_t*

Definition at line 155 of file tc_arguments.h.

#define TC_next_argument (   a)    ((a == 0) ? 0 : ((a->i < a->number_of_arguments) ? (a->arguments[a->i++].val_union.str_value) : 0))

Returns the current argument from the list of Teamcenter arguments, assuming that it is a string.
If there is no more argument in the list, it returns 0.

Subsequently, the position cursor is increased by one.

Parameters
a(I) TC_argument_list_t*

Definition at line 165 of file tc_arguments.h.

#define TC_next_int_argument (   a)    ((a == 0) ? 0 : ((a->i < a->number_of_arguments) ? (a->arguments[a->i++].val_union.int_value) : 0))

Returns the current argument from the list of Teamcenter arguments, assuming that it is an integer.
If there is no more argument in the list, it returns 0.

Subsequently, the position cursor is increased by one.

Parameters
a(I) TC_argument_list_t*

Definition at line 176 of file tc_arguments.h.

#define TC_number_of_arguments (   a)    ((a == 0) ? 0 : a->number_of_arguments)

Returns the total number of Teamcenter arguments contained in a pointer to TC_argument_list_t.

Parameters
a(I) TC_argument_list_t*

Definition at line 147 of file tc_arguments.h.

Typedef Documentation

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;
}
typedef struct TC_argument_s TC_argument_t

Argument processing for registered functions.
It is often used in an array of instances (refer to TC_argument_list_t).

Enumeration Type Documentation

Enumerator
TC_uninitialized 
TC_initializing 
TC_initialized 

Definition at line 23 of file tc_arguments.h.