Main Page | Modules | Files | Functions | Code Elements | Data Structures | Deprecated

tccore/method.h

Go to the documentation of this file.
00001 /*==============================================================================
00002                 Copyright (c) 2003-2005 UGS Corporation
00003                    Unpublished - All Rights Reserved
00004  ==============================================================================*/
00005 
00012 /*  */
00013 
00014 #ifndef METHOD_H
00015 #define METHOD_H
00016 
00017 #include <unidefs.h>
00018 #include <tc/emh.h>
00019 #include <tc/tc_startup.h>
00020 #include <tc/tc_arguments.h>
00021 #include <fclasses/tc_stdarg.h>
00022 #include <tccore/libtccore_exports.h>
00023 
00044 typedef struct METHOD_id_s
00045 {
00046     int   reserved;    
00047     void* id;
00048 } METHOD_id_t;
00049 
00053 typedef struct METHOD_message_s
00054 {
00055     tag_t                 object;       
00056     METHOD_id_t           method;
00057     void*                 system_data;  
00058     TC_argument_list_t* user_args;    
00059     tag_t                 object_tag;
00060     const char*           prop_name;
00061     void*                 imanProp;     
00062     void*                 propDesc;     
00063 } METHOD_message_t;
00064 
00071 typedef int (* METHOD_function_t)(
00072     METHOD_message_t*,
00073     va_list
00074     );
00075 
00076 typedef enum METHOD_action_type_e
00077 {
00078     METHOD_pre_action_type,
00079     METHOD_post_action_type
00080 } METHOD_action_type_t;
00081 
00091 #ifdef __cplusplus
00092 extern "C"{
00093 #endif
00094 
00106 extern TCCORE_API int METHOD_get_message_id(
00107     const char*         msg_name,   
00109     int*                msg_id      
00110     );
00111 
00112 extern TCCORE_API int METHOD_get_message_name ( int msg_id, char **method_name );
00113 
00114 extern TCCORE_API int METHOD_get_prop_message_name ( int msg_id, const char *property_name, char **method_name );
00115 
00116 #ifdef __cplusplus
00117 }
00118 #endif
00119 
00125 #define METHOD_SETUP_MESSAGE(msg_name,msg_id)                                       \
00126 static int  (msg_id) = 0;                                                           \
00127 if ( (msg_id) == 0 )                                                                \
00128 {                                                                                   \
00129     int  setup_err = METHOD_get_message_id( (msg_name), &(msg_id) );                \
00130     if ( setup_err != ITK_ok )                                                      \
00131     {                                                                               \
00132         TC_write_syslog ("No method defined for message name '%s'\n", msg_name);  \
00133         EMH_store_error( EMH_severity_error, setup_err );                           \
00134         return setup_err;                                                           \
00135     }                                                                               \
00136 }
00137 
00145 #ifdef __cplusplus
00146 extern "C"{
00147 #endif
00148 
00158 extern TCCORE_API int  METHOD_attach_action(
00159     const char* typeName,   
00160     const char* methodName, 
00161     int prePostFlag,        
00162     METHOD_function_t fn,   
00163     TC_argument_list_t* userData    
00165     );
00166 
00174 extern TCCORE_API int  METHOD_register_method(
00175     const char*           type_name,    
00176     const char*           msg_name,     
00177     METHOD_function_t     base_action,  
00178     TC_argument_list_t* user_args,    
00180     METHOD_id_t*          method_id     
00182     );
00183 
00189 extern TCCORE_API int  METHOD_add_pre_condition(
00190     METHOD_id_t           method_id,                
00191     METHOD_function_t     pre_condition_handler,    
00192     TC_argument_list_t* user_args                 
00194     );
00195 
00200 extern TCCORE_API int  METHOD_add_action(
00201     METHOD_id_t           method_id,        
00202     METHOD_action_type_t  action_type,      
00203     METHOD_function_t     action_handler,   
00204     TC_argument_list_t* user_args         
00206     );
00207 
00216 extern TCCORE_API int  METHOD_add_action2(
00217     METHOD_id_t           method_id,        
00218     METHOD_action_type_t  action_type,      
00219     METHOD_function_t     action_handler,   
00220     TC_argument_list_t*   user_args,        
00222     logical               auto_dispatched   
00223     );
00224 
00243 extern TCCORE_API int METHOD_find_method(
00244     const char*         type_name,  
00245     const char*         msg_name,   
00246     METHOD_id_t*        method_id   
00247     );
00248 
00249 
00254 extern  TCCORE_API  int  METHOD_find_dynamic_method(
00255     const char*     type_name,      
00256     const char*     msg_name,       
00257     METHOD_id_t*    method_id       
00258     );
00259 
00271 extern TCCORE_API int METHOD_execute(
00272     tag_t               object,     
00273     int                 msg_id,     
00274     ...                             
00275     );
00276 
00284 extern TCCORE_API int METHOD_execute_using(
00285     tag_t               object,     
00288     tag_t               tc_type,    
00289     int                 msg_id,     
00290     ...                             
00291     );
00292 
00299 extern TCCORE_API int METHOD_check_pre_conditions(
00300     tag_t               object, 
00301     int                 msg_id, 
00302     ...                         
00303     );
00304 
00314 extern TCCORE_API int METHOD_check_pre_conditions_message(
00315     tag_t               object, 
00316     int                 msg_id, 
00317     ...                         
00318     );
00319 
00323 extern TCCORE_API int  METHOD_call_pre_action(
00324     tag_t               object, 
00325     int                 msg_id, 
00326     ...                         
00327     );
00328 
00338 extern TCCORE_API int  METHOD_call_pre_action_message(
00339     tag_t               object, 
00340     int                 msg_id, 
00341     ...                         
00342     );
00343 
00351 extern TCCORE_API int  METHOD_register_prop_method(
00352     const char*           type_name,        
00354     const char*           property_name,    
00355     const char*           msg_name,         
00356     METHOD_function_t     base_action,      
00357     TC_argument_list_t* user_args,        
00359     METHOD_id_t*          method_id         
00361     );
00362 
00367 extern TCCORE_API int METHOD_find_prop_method(
00368     const char*         type_name,      
00369     const char*         property_name,  
00370     const char*         msg_name,       
00371     METHOD_id_t*        method_id       
00372     );
00373 
00385 extern TCCORE_API int METHOD_get_prop_message_id(
00386     const char*         msg_name,       
00388     const char*         property_name,  
00389     int*                msg_id          
00390     );
00391 
00396 extern TCCORE_API int METHOD_merge_prop_message_id(
00397     int                 merge_msg_id,   
00398     const char*         property_name,  
00399     int*                msg_id          
00400     );
00401 
00402 extern TCCORE_API int METHOD__is_prop_registered(
00403     tag_t               objTag,
00404     const char*         methodName,
00405     const char*         propName,
00406     logical*            registered
00407     );
00408 
00412 extern TCCORE_API int  METHOD_call_post_action
00413     ( tag_t                   object,                   
00414       int                     msg_id,                   
00415       ...
00416     );
00417 
00427 extern TCCORE_API int  METHOD_call_post_action_message
00428     ( tag_t                   object,                   
00429       int                     msg_id,                   
00430       ...
00431     );
00432 
00433 extern TCCORE_API int METHOD__register_operationFn(
00434     const char*           type_name,    
00435     const char*           msg_name,     
00436     METHOD_function_t     base_action,  
00437     TC_argument_list_t*   user_args,    
00439     METHOD_id_t*          method_id     
00441                   );
00442 
00443 extern TCCORE_API int  METHOD__register_prop_operationFn(
00444     const char*           type_name,        
00446     const char*           property_name,    
00447     const char*           msg_name,         
00448     METHOD_function_t     base_action,      
00449     TC_argument_list_t*   user_args,        
00451     METHOD_id_t*          method_id         
00453     );
00454 
00455 #ifdef __cplusplus
00456 }
00457 #endif
00458 
00462 #define METHOD_SETUP_PROP_MESSAGE(msg_name,property_name,msg_id)                            \
00463 static int  (msg_id) = 0;                                                                   \
00464 if ( (msg_id) == 0 )                                                                        \
00465 {                                                                                           \
00466     int setup_err = METHOD_get_prop_message_id( (msg_name), (property_name), &(msg_id) );   \
00467     if ( setup_err != ITK_ok ) return setup_err;                                            \
00468     else if ((msg_id) == 0)                                                                 \
00469 { TC_write_syslog ("File %s; Line # %d; no message '%s' registered for property '%s'",    \
00470                      __FILE__, __LINE__, (msg_name), (property_name));                      \
00471         return ITK_general_user_error;                                                      \
00472       }                                                                                     \
00473 }                                                                                           \
00474 else                                                                                        \
00475 {                                                                                           \
00476     int setup_err = METHOD_merge_prop_message_id( (msg_id), (property_name), &(msg_id) );   \
00477     if ( setup_err != ITK_ok ) return setup_err;                                            \
00478 }
00479 
00480 #define METHOD_PROP_MESSAGE_OBJECT(msg, objectTag) (objectTag) = (msg)->object_tag;
00481 
00482 #define METHOD_PROP_MESSAGE_PROP_NAME(msg, propName) (propName) = (msg)->prop_name;
00483 
00486 #include <tccore/libtccore_undef.h>
00487 #endif