stage_internal.h
Go to the documentation of this file.00001 #ifndef _STAGE_INTERNAL_H 00002 #define _STAGE_INTERNAL_H 00003 00004 // internal function declarations that are not part of the external 00005 // interface to Stage 00006 00007 00008 #include <assert.h> 00009 #include <pthread.h> 00010 #include <semaphore.h> 00011 #include <math.h> // for lrint() in macros 00012 #include <stdlib.h> 00013 #include <stdio.h> 00014 #include <sys/socket.h> 00015 #include <netdb.h> 00016 #include <string.h> 00017 00018 #include "stage.h" 00019 #include "config.h" // results of autoconf's system configuration tests 00020 #include "replace.h" // Stage's implementations of missing system calls 00021 #include "rtk.h" // and graphics stuff pulled from Andrew Howard's RTK2 library 00022 00023 #if INCLUDE_GNOME 00024 #include <libgnomecanvas/libgnomecanvas.h> 00025 #endif 00026 00027 00038 #include <glib.h> 00039 00040 #ifdef __cplusplus 00041 extern "C" { 00042 #endif 00043 00045 typedef struct 00046 { 00047 00048 // Gtk stuff 00049 GtkWidget* frame; 00050 GtkWidget *layout; 00051 GtkWidget *menu_bar; 00052 //GtkWidget* scrolled_win; 00053 00054 // The status bar widget 00055 GtkStatusbar *status_bar; 00056 GtkProgressBar *perf_bar; 00057 GtkProgressBar *rt_bar; 00058 GtkLabel *clock_label; 00059 00060 #if INCLUDE_GNOME 00061 // modern GNOMECANVAS style 00062 GnomeCanvas* gcanvas; 00063 double zoom; 00064 #else 00065 // vintage RTK style 00066 stg_rtk_canvas_t* canvas; 00067 stg_rtk_fig_t* bg; // background 00068 stg_rtk_fig_t* matrix; 00069 stg_rtk_fig_t* matrix_tree; 00070 stg_rtk_fig_t* poses; 00071 #endif 00072 00073 stg_world_t* world; // every window shows a single world 00074 00075 GtkStatusbar* statusbar; 00076 GtkLabel* timelabel; 00077 00078 int wf_section; // worldfile section for load/save 00079 00080 gboolean show_matrix; 00081 gboolean fill_polygons; 00082 gboolean show_geom; 00083 gboolean show_polygons; 00084 gboolean show_grid; 00085 00086 int frame_series; 00087 int frame_index; 00088 int frame_callback_tag; 00089 int frame_interval; 00090 int frame_format; 00091 00092 stg_model_t* selection_active; 00093 00094 GList* toggle_list; 00095 00096 } gui_window_t; 00097 00098 void gui_startup( int* argc, char** argv[] ); 00099 void gui_poll( void ); 00100 void gui_shutdown( void ); 00101 00102 void gui_load( gui_window_t* win, int section ); 00103 void gui_save( gui_window_t* win ); 00104 00105 gui_window_t* gui_world_create( stg_world_t* world ); 00106 void gui_world_destroy( stg_world_t* world ); 00107 int gui_world_update( stg_world_t* world ); 00108 void stg_world_add_model( stg_world_t* world, stg_model_t* mod ); 00109 void gui_world_geom( stg_world_t* world ); 00110 00111 void gui_model_create( stg_model_t* model ); 00112 void gui_model_destroy( stg_model_t* model ); 00113 void gui_model_display_pose( stg_model_t* mod, char* verb ); 00114 void gui_model_features( stg_model_t* mod ); 00115 void gui_model_geom( stg_model_t* model ); 00116 void gui_model_mouse(stg_rtk_fig_t *fig, int event, int mode); 00117 void gui_model_nose( stg_model_t* model ); 00118 void gui_window_menus_create( gui_window_t* win ); 00119 void gui_window_menus_destroy( gui_window_t* win ); 00120 00121 // callback functions that handle property changes, mostly for drawing stuff in the GUI 00122 int gui_model_polygons( stg_model_t* mod, void* userp ); 00123 int gui_model_grid( stg_model_t* mod, void* userp ); 00124 int gui_model_move( stg_model_t* mod, void* userp ); 00125 int gui_model_mask( stg_model_t* mod, void* userp ); 00126 int gui_model_lines( stg_model_t* mod, void* userp ); 00127 00128 00129 void gui_add_view_item( const gchar *name, 00130 const gchar *label, 00131 const gchar *tooltip, 00132 GCallback callback, 00133 gboolean is_active, 00134 void* userdata ); 00135 00136 void gui_add_tree_item( stg_model_t* mod ); 00137 00138 00141 typedef struct 00142 { 00143 stg_model_callback_t callback; 00144 void* arg; 00145 } stg_cbarg_t; 00146 00147 // callback functions 00148 //typedef void(*func_init_t)(struct _stg_model*); 00149 typedef int(*func_update_t)(struct _stg_model*); 00150 typedef int(*func_startup_t)(struct _stg_model*); 00151 typedef int(*func_shutdown_t)(struct _stg_model*); 00152 typedef void(*func_load_t)(struct _stg_model*); 00153 typedef void(*func_save_t)(struct _stg_model*); 00154 00155 typedef struct 00156 { 00157 stg_model_t* mod; 00158 void* member; 00159 char* name; 00160 stg_model_callback_t callback_on; 00161 stg_model_callback_t callback_off; 00162 void* arg_on; // argument to callback_on 00163 void* arg_off; // argument to callback_off 00164 //int default_state; // disabled = 0 00165 GtkAction* action; // action associated with this toggle, may be NULL 00166 char* path; 00167 } stg_property_toggle_args_t; 00168 00169 00170 typedef struct { 00171 const char* keyword; 00172 stg_model_initializer_t initializer; 00173 } stg_type_record_t; 00174 00175 struct _stg_model 00176 { 00177 stg_id_t id; // used as hash table key 00178 stg_world_t* world; // pointer to the world in which this model exists 00179 char token[STG_TOKEN_MAX]; // automatically-generated unique ID string 00180 stg_type_record_t* typerec; 00181 00182 struct _stg_model *parent; // the model that owns this one, possibly NULL 00183 00184 GPtrArray* children; // the models owned by this model 00185 00186 // a datalist can contain arbitrary named data items. Can be used 00187 // by derived model types to store properties, and for user code 00188 // to associate arbitrary items with a model. 00189 GData* props; 00190 00191 // a datalist of stg_rtk_figs, indexed by name (string) 00192 GData* figs; 00193 00194 //#if INCLUDE_GNOME 00195 //GnomeCanvasGroup* grp; 00196 //GnomeCanvasGroup* cgrp; 00197 //#endif 00198 00199 stg_pose_t pose; 00200 stg_velocity_t velocity; 00201 stg_polygon_t* polygons; 00202 size_t polygons_count; 00203 stg_watts_t watts; //< power consumed by this model 00204 stg_color_t color; 00205 stg_kg_t mass; 00206 stg_geom_t geom; 00207 int laser_return; 00208 int obstacle_return; 00209 int blob_return; 00210 int gripper_return; 00211 int audio_return; 00212 int ranger_return; 00213 int fiducial_return; 00214 int fiducial_key; 00215 int boundary; 00216 stg_meters_t map_resolution; 00217 stg_bool_t stall; 00218 00219 int gui_nose; 00220 int gui_grid; 00221 int gui_outline; 00222 int gui_mask; 00223 00224 GHashTable* callbacks; 00225 00226 // the number of children of each type is counted so we can 00227 // automatically generate names for them 00228 int child_type_count[256]; 00229 00230 int subs; // the number of subscriptions to this model 00231 00232 stg_msec_t interval; // time between updates in ms 00233 stg_msec_t interval_elapsed; // time since last update in ms 00234 00235 stg_bool_t disabled; // if non-zero, the model is disabled 00236 00237 // type-dependent functions for this model, implementing simple 00238 // polymorphism 00239 //stg_model_initializer_t initializer; 00240 func_startup_t f_startup; 00241 func_shutdown_t f_shutdown; 00242 func_update_t f_update; 00243 func_load_t f_load; 00244 func_save_t f_save; 00245 00246 void *data, *cmd, *cfg; 00247 size_t data_len, cmd_len, cfg_len; 00248 00249 // XX experimental 00250 stg_polyline_t* lines; 00251 size_t lines_count; 00252 00254 // allow exclusive access to this model 00255 // pthread_mutex_t mutex; 00256 00257 // end experimental 00258 }; 00259 00260 00261 // internal functions 00262 00263 int _model_update( stg_model_t* mod ); 00264 int _model_startup( stg_model_t* mod ); 00265 int _model_shutdown( stg_model_t* mod ); 00266 00267 void model_change( stg_model_t* mod, void* address ); 00268 00269 void stg_model_update_velocity( stg_model_t* model ); 00270 int stg_model_update_pose( stg_model_t* model ); 00271 void stg_model_energy_consume( stg_model_t* mod, stg_watts_t rate ); 00272 void stg_model_map( stg_model_t* mod, gboolean render ); 00273 void stg_model_map_with_children( stg_model_t* mod, gboolean render ); 00274 00275 stg_rtk_fig_t* stg_model_prop_fig_create( stg_model_t* mod, 00276 stg_rtk_fig_t* array[], 00277 stg_id_t propid, 00278 stg_rtk_fig_t* parent, 00279 int layer ); 00280 00281 void stg_model_render_geom( stg_model_t* mod ); 00282 void stg_model_render_pose( stg_model_t* mod ); 00283 void stg_model_render_polygons( stg_model_t* mod ); 00284 00285 int stg_fig_clear_cb( stg_model_t* mod, char* name, 00286 void* data, size_t len, void* userp ); 00287 00288 stg_rtk_fig_t* stg_model_fig_create( stg_model_t* mod, 00289 const char* figname, 00290 const char* parentname, 00291 int layer ); 00292 00296 stg_rtk_fig_t* stg_model_fig_get_or_create( stg_model_t* mod, 00297 const char* figname, 00298 const char* parentname, 00299 int layer ); 00300 00301 stg_rtk_fig_t* stg_model_get_fig( stg_model_t* mod, const char* figname ); 00302 void stg_model_fig_clear( stg_model_t* mod, const char* figname ); 00303 00304 // defines a simulated world 00305 struct _stg_world 00306 { 00307 stg_id_t id; 00308 00309 GHashTable* models; 00310 GHashTable* models_by_name; 00311 00312 GList* selected_models; 00313 00314 00315 stg_meters_t width; 00316 stg_meters_t height; 00317 00321 int child_type_count[256]; 00322 00323 struct _stg_matrix* matrix; 00324 00325 char* token; 00326 00327 stg_msec_t sim_time; 00328 stg_msec_t sim_interval; 00329 00332 stg_msec_t wall_interval; 00333 stg_msec_t wall_last_update; 00334 00335 stg_msec_t gui_interval; 00336 stg_msec_t gui_last_update; 00337 00338 stg_msec_t gui_menu_interval; 00339 stg_msec_t gui_menu_last_update; 00340 00341 00346 stg_msec_t real_interval_measured; 00347 00348 double ppm; 00349 00350 gboolean paused; 00351 00352 gboolean destroy; 00353 00354 gui_window_t* win; 00355 00356 int subs; 00357 }; 00358 00359 // ROTATED RECTANGLES ------------------------------------------------- 00360 00367 typedef struct 00368 { 00369 stg_pose_t pose; 00370 stg_size_t size; 00371 } stg_rotrect_t; // rotated rectangle 00372 00376 void stg_rotrects_normalize( stg_rotrect_t* rects, int num ); 00377 00383 int stg_rotrects_from_image_file( const char* filename, 00384 stg_rotrect_t** rects, 00385 int* rect_count, 00386 int* widthp, int* heightp ); 00387 00388 00392 stg_polygon_t* stg_polygons_from_rotrects( stg_rotrect_t* rects, size_t count, 00393 double width, double height ); 00394 00398 // MATRIX ----------------------------------------------------------------------- 00399 00407 typedef struct stg_cell 00408 { 00409 void* data; 00410 double x, y; 00411 double size; 00412 00413 // bounding box 00414 double xmin,ymin,xmax,ymax; 00415 00416 stg_rtk_fig_t* fig; // for debugging 00417 00418 struct stg_cell* children[4]; 00419 struct stg_cell* parent; 00420 } stg_cell_t; 00421 00424 stg_cell_t* stg_cell_locate( stg_cell_t* cell, double x, double y ); 00425 00426 void stg_cell_unrender( stg_cell_t* cell ); 00427 void stg_cell_render( stg_cell_t* cell ); 00428 void stg_cell_render_tree( stg_cell_t* cell ); 00429 void stg_cell_unrender_tree( stg_cell_t* cell ); 00430 00432 typedef struct _stg_matrix 00433 { 00434 double ppm; // pixels per meter (1/resolution) 00435 double width, height; 00436 00437 // A quad tree of cells. Each leaf node contains a list of 00438 // pointers to objects located at that cell 00439 stg_cell_t* root; 00440 00441 // hash table stores all the pointers to objects rendered in the 00442 // quad tree, each associated with a list of cells in which it is 00443 // rendered. This allows us to remove objects from the tree 00444 // without doing the geometry again 00445 GHashTable* ptable; 00446 00447 /* TODO */ 00448 // lists of cells that have changed recently. This is used by the 00449 // GUI to render cells very quickly, and could also be used by devices 00450 //GSList* cells_changed; 00451 00452 // debug figure. if this is non-NULL, debug info is drawn here 00453 stg_rtk_fig_t* fig; 00454 00455 // todo - record a timestamp for matrix mods so devices can see if 00456 //the matrix has changed since they last peeked into it 00457 // stg_msec_t last_mod_time; 00458 } stg_matrix_t; 00459 00460 00463 stg_matrix_t* stg_matrix_create( double ppm, double width, double height ); 00464 00468 void stg_matrix_destroy( stg_matrix_t* matrix ); 00469 00472 void stg_matrix_clear( stg_matrix_t* matrix ); 00473 00476 void* stg_matrix_cell_get( stg_matrix_t* matrix, int r, double x, double y); 00477 00480 void stg_matrix_cell_append( stg_matrix_t* matrix, 00481 double x, double y, void* object ); 00482 00485 void stg_matrix_remove_obect( stg_matrix_t* matrix, void* object ); 00486 00489 void stg_matrix_cell_remove( stg_matrix_t* matrix, 00490 double x, double y, void* object ); 00491 00495 void stg_matrix_rectangle( stg_matrix_t* matrix, 00496 double px, double py, double pth, 00497 double dx, double dy, 00498 void* object ); 00499 00502 void stg_matrix_line( stg_matrix_t* matrix, 00503 double x1, double y1, 00504 double x2, double y2, 00505 void* object ); 00506 00509 typedef struct 00510 { 00511 stg_meters_t x1, y1, x2, y2; 00512 } stg_line_t; 00513 00514 00517 void stg_matrix_lines( stg_matrix_t* matrix, 00518 stg_line_t* lines, int num_lines, 00519 void* object ); 00520 00523 void stg_matrix_polygons( stg_matrix_t* matrix, 00524 double x, double y, double a, 00525 stg_polygon_t* polys, int num_polys, 00526 void* object ); 00527 00529 void stg_matrix_polylines( stg_matrix_t* matrix, 00530 double x, double y, double a, 00531 stg_polyline_t* polylines, int num_polylines, 00532 void* object ); 00533 00536 void stg_matrix_remove_object( stg_matrix_t* matrix, void* object ); 00537 00538 00539 // RAYTRACE ITERATORS ------------------------------------------------------------- 00540 00541 typedef struct 00542 { 00543 double x, y, a; 00544 double cosa, sina, tana; 00545 double range; 00546 double max_range; 00547 double* incr; 00548 00549 GSList* models; 00550 int index; 00551 stg_matrix_t* matrix; 00552 00553 } itl_t; 00554 00555 typedef enum { PointToPoint=0, PointToBearingRange } itl_mode_t; 00556 00557 typedef int(*stg_itl_test_func_t)(stg_model_t* finder, stg_model_t* found ); 00558 00559 itl_t* itl_create( double x, double y, double a, double b, 00560 stg_matrix_t* matrix, itl_mode_t pmode ); 00561 00562 void itl_destroy( itl_t* itl ); 00563 void itl_raytrace( itl_t* itl ); 00564 00565 stg_model_t* itl_first_matching( itl_t* itl, 00566 stg_itl_test_func_t func, 00567 stg_model_t* finder ); 00568 00569 double itl_wall_distance( itl_t* itl, 00570 stg_itl_test_func_t func, 00571 stg_model_t* finder, stg_model_t* otherrobot); 00579 // C wrappers for C++ worldfile functions 00580 void wf_warn_unused( void ); 00581 int wf_property_exists( int section, char* token ); 00582 int wf_read_int( int section, char* token, int def ); 00583 double wf_read_length( int section, char* token, double def ); 00584 double wf_read_angle( int section, char* token, double def ); 00585 double wf_read_float( int section, char* token, double def ); 00586 const char* wf_read_tuple_string( int section, char* token, int index, char* def ); 00587 double wf_read_tuple_float( int section, char* token, int index, double def ); 00588 double wf_read_tuple_length( int section, char* token, int index, double def ); 00589 double wf_read_tuple_angle( int section, char* token, int index, double def ); 00590 const char* wf_read_string( int section, char* token, char* def ); 00591 00592 void wf_write_int( int section, char* token, int value ); 00593 void wf_write_length( int section, char* token, double value ); 00594 void wf_write_angle( int section, char* token, double value ); 00595 void wf_write_float( int section, char* token, double value ); 00596 void wf_write_tuple_string( int section, char* token, int index, char* value ); 00597 void wf_write_tuple_float( int section, char* token, int index, double value ); 00598 void wf_write_tuple_length( int section, char* token, int index, double value ); 00599 void wf_write_tuple_angle( int section, char* token, int index, double value ); 00600 void wf_write_string( int section, char* token, char* value ); 00601 00602 void wf_save( void ); 00603 void wf_load( char* path ); 00604 int wf_section_count( void ); 00605 const char* wf_get_section_type( int section ); 00606 int wf_get_parent_section( int section ); 00607 const char* wf_get_filename( void); 00608 00611 // CALLBACK WRAPPERS ------------------------------------------------------------ 00612 00613 // callback wrappers for other functions 00614 void model_update_cb( gpointer key, gpointer value, gpointer user ); 00615 void model_print_cb( gpointer key, gpointer value, gpointer user ); 00616 void model_destroy_cb( gpointer mod ); 00617 00618 00620 // end of libstage_internal documentation 00621 00622 00623 // end documentation group stage 00629 // TODO - some of this needs to be implemented, the rest junked. 00630 00631 /* // -------------------------------------------------------------- */ 00632 00633 /* // standard energy consumption of some devices in W. */ 00634 /* // */ 00635 /* // The MOTIONKG value is a hack to approximate cost of motion, as */ 00636 /* // Stage does not yet have an acceleration model. */ 00637 /* // */ 00638 /* #define STG_ENERGY_COST_LASER 20.0 // 20 Watts! (LMS200 - from SICK web site) */ 00639 /* #define STG_ENERGY_COST_FIDUCIAL 10.0 // 10 Watts */ 00640 /* #define STG_ENERGY_COST_RANGER 0.5 // 500mW (estimate) */ 00641 /* #define STG_ENERGY_COST_MOTIONKG 10.0 // 10 Watts per KG when moving */ 00642 /* #define STG_ENERGY_COST_BLOB 4.0 // 4W (estimate) */ 00643 00644 /* typedef struct */ 00645 /* { */ 00646 /* stg_joules_t joules; // current energy stored in Joules/1000 */ 00647 /* stg_watts_t watts; // current power expenditure in mW (mJoules/sec) */ 00648 /* int charging; // 1 if we are receiving energy, -1 if we are */ 00649 /* // supplying energy, 0 if we are neither charging nor */ 00650 /* // supplying energy. */ 00651 /* stg_meters_t range; // the range that our charging probe hit a charger */ 00652 /* } stg_energy_data_t; */ 00653 00654 /* typedef struct */ 00655 /* { */ 00656 /* stg_joules_t capacity; // maximum energy we can store (we start fully charged) */ 00657 /* stg_meters_t probe_range; // the length of our recharge probe */ 00658 /* //stg_pose_t probe_pose; // TODO - the origin of our probe */ 00659 00660 /* stg_watts_t give_rate; // give this many Watts to a probe that hits me (possibly 0) */ 00661 00662 /* stg_watts_t trickle_rate; // this much energy is consumed or */ 00663 /* // received by this device per second as a */ 00664 /* // baseline trickle. Positive values mean */ 00665 /* // that the device is just burning energy */ 00666 /* // stayting alive, which is appropriate */ 00667 /* // for most devices. Negative values mean */ 00668 /* // that the device is receiving energy */ 00669 /* // from the environment, simulating a */ 00670 /* // solar cell or some other ambient energy */ 00671 /* // collector */ 00672 00673 /* } stg_energy_config_t; */ 00674 00675 00676 /* // BLINKENLIGHT ------------------------------------------------------------ */ 00677 00678 /* // a number of milliseconds, used for example as the blinkenlight interval */ 00679 /* #define STG_LIGHT_ON UINT_MAX */ 00680 /* #define STG_LIGHT_OFF 0 */ 00681 00682 //typedef int stg_interval_ms_t; 00683 00684 00685 /* // TOKEN ----------------------------------------------------------------------- */ 00686 /* // token stuff for parsing worldfiles - this may one day replace 00687 the worldfile c++ code */ 00688 00689 /* #define CFG_OPEN '(' */ 00690 /* #define CFG_CLOSE ')' */ 00691 /* #define STR_OPEN '\"' */ 00692 /* #define STR_CLOSE '\"' */ 00693 /* #define TPL_OPEN '[' */ 00694 /* #define TPL_CLOSE ']' */ 00695 00696 /* typedef enum { */ 00697 /* STG_T_NUM = 0, */ 00698 /* STG_T_BOOLEAN, */ 00699 /* STG_T_MODELPROP, */ 00700 /* STG_T_WORLDPROP, */ 00701 /* STG_T_NAME, */ 00702 /* STG_T_STRING, */ 00703 /* STG_T_KEYWORD, */ 00704 /* STG_T_CFG_OPEN, */ 00705 /* STG_T_CFG_CLOSE, */ 00706 /* STG_T_TPL_OPEN, */ 00707 /* STG_T_TPL_CLOSE, */ 00708 /* } stg_token_type_t; */ 00709 00710 00711 00712 00713 /* typedef struct stg_token */ 00714 /* { */ 00715 /* char* token; ///< the text of the token */ 00716 /* stg_token_type_t type; ///< the type of the token */ 00717 /* unsigned int line; ///< the line on which the token appears */ 00718 00719 /* struct stg_token* next; ///< linked list support */ 00720 /* struct stg_token* child; ///< tree support */ 00721 00722 /* } stg_token_t; */ 00723 00724 /* stg_token_t* stg_token_next( stg_token_t* tokens ); */ 00725 /* /// print [token] formatted for a human reader, with a string [prefix] */ 00726 /* void stg_token_print( char* prefix, stg_token_t* token ); */ 00727 00728 /* /// print a token array suitable for human reader */ 00729 /* void stg_tokens_print( stg_token_t* tokens ); */ 00730 /* void stg_tokens_free( stg_token_t* tokens ); */ 00731 00732 /* /// create a new token structure from the arguments */ 00733 /* stg_token_t* stg_token_create( const char* token, stg_token_type_t type, int line ); */ 00734 00735 /* /// add a token to a list */ 00736 /* stg_token_t* stg_token_append( stg_token_t* head, */ 00737 /* char* token, stg_token_type_t type, int line ); */ 00738 00739 /* const char* stg_token_type_string( stg_token_type_t type ); */ 00740 00741 /* const char* stg_model_type_string( stg_model_type_t type ); */ 00742 00743 /* // functions for parsing worldfiles */ 00744 /* stg_token_t* stg_tokenize( FILE* wf ); */ 00745 /* //stg_world_t* sc_load_worldblock( stg_client_t* cli, stg_token_t** tokensptr ); */ 00746 /* //stg_model_t* sc_load_modelblock( stg_world_t* world, stg_model_t* parent, */ 00747 /* // stg_token_t** tokensptr ); */ 00748 00749 00750 00751 00752 #ifdef __cplusplus 00753 } 00754 #endif 00755 00756 // Error macros - output goes to stderr 00757 #define PRINT_ERR(m) fprintf( stderr, "\033[41merr\033[0m: "m" (%s %s)\n", __FILE__, __FUNCTION__) 00758 #define PRINT_ERR1(m,a) fprintf( stderr, "\033[41merr\033[0m: "m" (%s %s)\n", a, __FILE__, __FUNCTION__) 00759 #define PRINT_ERR2(m,a,b) fprintf( stderr, "\033[41merr\033[0m: "m" (%s %s)\n", a, b, __FILE__, __FUNCTION__) 00760 #define PRINT_ERR3(m,a,b,c) fprintf( stderr, "\033[41merr\033[0m: "m" (%s %s)\n", a, b, c, __FILE__, __FUNCTION__) 00761 #define PRINT_ERR4(m,a,b,c,d) fprintf( stderr, "\033[41merr\033[0m: "m" (%s %s)\n", a, b, c, d, __FILE__, __FUNCTION__) 00762 #define PRINT_ERR5(m,a,b,c,d,e) fprintf( stderr, "\033[41merr\033[0m: "m" (%s %s)\n", a, b, c, d, e, __FILE__, __FUNCTION__) 00763 00764 // Warning macros 00765 #define PRINT_WARN(m) printf( "\033[44mwarn\033[0m: "m" (%s %s)\n", __FILE__, __FUNCTION__) 00766 #define PRINT_WARN1(m,a) printf( "\033[44mwarn\033[0m: "m" (%s %s)\n", a, __FILE__, __FUNCTION__) 00767 #define PRINT_WARN2(m,a,b) printf( "\033[44mwarn\033[0m: "m" (%s %s)\n", a, b, __FILE__, __FUNCTION__) 00768 #define PRINT_WARN3(m,a,b,c) printf( "\033[44mwarn\033[0m: "m" (%s %s)\n", a, b, c, __FILE__, __FUNCTION__) 00769 #define PRINT_WARN4(m,a,b,c,d) printf( "\033[44mwarn\033[0m: "m" (%s %s)\n", a, b, c, d, __FILE__, __FUNCTION__) 00770 #define PRINT_WARN5(m,a,b,c,d,e) printf( "\033[44mwarn\033[0m: "m" (%s %s)\n", a, b, c, d, e, __FILE__, __FUNCTION__) 00771 00772 // Message macros 00773 #ifdef DEBUG 00774 #define PRINT_MSG(m) printf( "Stage: "m" (%s %s)\n", __FILE__, __FUNCTION__) 00775 #define PRINT_MSG1(m,a) printf( "Stage: "m" (%s %s)\n", a, __FILE__, __FUNCTION__) 00776 #define PRINT_MSG2(m,a,b) printf( "Stage: "m" (%s %s)\n", a, b, __FILE__, __FUNCTION__) 00777 #define PRINT_MSG3(m,a,b,c) printf( "Stage: "m" (%s %s)\n", a, b, c, __FILE__, __FUNCTION__) 00778 #define PRINT_MSG4(m,a,b,c,d) printf( "Stage: "m" (%s %s)\n", a, b, c, d, __FILE__, __FUNCTION__) 00779 #define PRINT_MSG5(m,a,b,c,d,e) printf( "Stage: "m" (%s %s)\n", a, b, c, d, e,__FILE__, __FUNCTION__) 00780 #else 00781 #define PRINT_MSG(m) printf( "Stage: "m"\n" ) 00782 #define PRINT_MSG1(m,a) printf( "Stage: "m"\n", a) 00783 #define PRINT_MSG2(m,a,b) printf( "Stage: "m"\n,", a, b ) 00784 #define PRINT_MSG3(m,a,b,c) printf( "Stage: "m"\n", a, b, c ) 00785 #define PRINT_MSG4(m,a,b,c,d) printf( "Stage: "m"\n", a, b, c, d ) 00786 #define PRINT_MSG5(m,a,b,c,d,e) printf( "Stage: "m"\n", a, b, c, d, e ) 00787 #endif 00788 00789 // DEBUG macros 00790 #ifdef DEBUG 00791 #define PRINT_DEBUG(m) printf( "debug: "m" (%s %s)\n", __FILE__, __FUNCTION__) 00792 #define PRINT_DEBUG1(m,a) printf( "debug: "m" (%s %s)\n", a, __FILE__, __FUNCTION__) 00793 #define PRINT_DEBUG2(m,a,b) printf( "debug: "m" (%s %s)\n", a, b, __FILE__, __FUNCTION__) 00794 #define PRINT_DEBUG3(m,a,b,c) printf( "debug: "m" (%s %s)\n", a, b, c, __FILE__, __FUNCTION__) 00795 #define PRINT_DEBUG4(m,a,b,c,d) printf( "debug: "m" (%s %s)\n", a, b, c ,d, __FILE__, __FUNCTION__) 00796 #define PRINT_DEBUG5(m,a,b,c,d,e) printf( "debug: "m" (%s %s)\n", a, b, c ,d, e, __FILE__, __FUNCTION__) 00797 #else 00798 #define PRINT_DEBUG(m) 00799 #define PRINT_DEBUG1(m,a) 00800 #define PRINT_DEBUG2(m,a,b) 00801 #define PRINT_DEBUG3(m,a,b,c) 00802 #define PRINT_DEBUG4(m,a,b,c,d) 00803 #define PRINT_DEBUG5(m,a,b,c,d,e) 00804 #endif 00805 00806 00807 00808 #endif // _STAGE_INTERNAL_H 00809
Generated on Thu Dec 13 13:55:21 2007 for Stage by 1.4.6