GetHashTable.c

Go to the documentation of this file.
00001 /*------------------------------------------------------------------------*/
00002 /* file: GetHashTable.c                                                   */
00003 /* Copyright INRIA 2006                                                   */
00004 /* Authors : Jean-Baptiste Silvy                                          */
00005 /* desc : implementation of the scilab hashtable for the get procedure    */
00006 /*------------------------------------------------------------------------*/
00007 
00008 #include "GetHashTable.h"
00009 #include "machine.h"
00010 #include "getHandleProperty.h"
00011 #include "sciprint.h"
00012 
00016 static BOOL getHashTableCreated = FALSE ;
00017 
00021 static GetPropertyHashTable * getHashTable = NULL ;
00022 
00027 typedef struct  
00028 {
00029   char            * key ;
00030   getPropertyFunc   accessor ;
00031 } getHashTableCouple ;
00032 
00038 #define NB_PROPERTIES 125
00039 
00044 static getHashTableCouple propertyTable[NB_PROPERTIES] =
00045 { { "figures_id"         , get_figures_id_property          },
00046   { "visible"            , get_visible_property             },
00047   { "pixel_drawing_mode" , get_pixel_drawing_mode_property  },
00048   { "old_style"          , get_old_style_property           },
00049   { "figure_style"       , get_figure_style_property        },
00050   { "auto_resize"        , get_auto_resize_property         },
00051   { "figure_position"    , get_figure_position_property     },
00052   { "axes_size"          , get_axes_size_property           },
00053   { "figure_size"        , get_figure_size_property         },
00054   { "figure_name"        , get_figure_name_property         },
00055   { "figure_id"          , get_figure_id_property           },
00056   { "rotation_style"     , get_rotation_style_property      },
00057   { "immediate_drawing"  , get_immediate_drawing_property   },
00058   { "pixmap"             , get_pixmap_property              },
00059   { "type"               , get_type_property                },
00060   { "parent"             , get_parent_property              },
00061   { "current_axes"       , get_current_axes_property        },
00062   { "current_figure"     , get_current_figure_property      },
00063   { "current_obj"        , get_current_entity_property      },
00064   { "current_entity"     , get_current_entity_property      },
00065   { "hdl"                , get_current_entity_property      },
00066   { "children"           , get_children_property            },
00067   { "default_figure"     , get_default_figure_property      },
00068   { "default_axes"       , get_default_axes_property        },
00069   { "color_map"          , get_color_map_property           },
00070   { "interp_color_vector", get_interp_color_vector_property },
00071   { "interp_color_mode"  , get_interp_color_mode_property   },
00072   { "background"         , get_background_property          },
00073   { "foreground"         , get_foreground_property          },
00074   { "fill_mode"          , get_fill_mode_property           },
00075   { "thickness"          , get_thickness_property           },
00076   { "arrow_size_factor"  , get_arrow_size_factor_property   },
00077   { "segs_color"         , get_segs_color_property          },
00078   { "line_style"         , get_line_style_property          },
00079   { "line_mode"          , get_line_mode_property           },
00080   { "surface_mode"       , get_surface_mode_property        },
00081   { "mark_style"         , get_mark_style_property          },
00082   { "mark_mode"          , get_mark_mode_property           },
00083   { "mark_size_unit"     , get_mark_size_unit_property      },
00084   { "mark_size"          , get_mark_size_property           },
00085   { "mark_foreground"    , get_mark_foreground_property     },
00086   { "mark_background"    , get_mark_background_property     },
00087   { "bar_layout"         , get_bar_layout_property          },
00088   { "bar_width"          , get_bar_width_property           },
00089   { "x_shift"            , get_x_shift_property             },
00090   { "y_shift"            , get_y_shift_property             },
00091   { "z_shift"            , get_z_shift_property             },
00092   { "polyline_style"     , get_polyline_style_property      },
00093   { "font_size"          , get_font_size_property           },
00094   { "font_angle"         , get_font_angle_property          },
00095   { "font_foreground"    , get_font_foreground_property     },
00096   { "font_color"         , get_font_color_property          },
00097   { "font_style"         , get_font_style_property          },
00098   { "font_name"          , get_font_name_property           },
00099   { "text_box_mode"      , get_text_box_mode_property       },
00100   { "auto_dimensionning" , get_auto_dimensionning_property  },
00101   { "alignment"          , get_alignment_property           },
00102   { "text_box"           , get_text_box_property            },
00103   { "text"               , get_text_property                },
00104   { "auto_clear"         , get_auto_clear_property          },
00105   { "auto_scale"         , get_auto_scale_property          },
00106   { "zoom_box"           , get_zoom_box_property            },
00107   { "zoom_state"         , get_zoom_state_property          },
00108   { "clip_box"           , get_clip_box_property            },
00109   { "clip_state"         , get_clip_state_property          },
00110   { "data"               , get_data_property                },
00111   { "callbackmevent"     , get_callbackmevent_property      },
00112   { "callback"           , get_callback_property            },
00113   { "x_label"            , get_x_label_property             },
00114   { "y_label"            , get_y_label_property             },
00115   { "z_label"            , get_z_label_property             },
00116   { "title"              , get_title_property               },
00117   { "log_flags"          , get_log_flags_property           },
00118   { "tics_direction"     , get_tics_direction_property      },
00119   { "x_location"         , get_x_location_property          },
00120   { "y_location"         , get_y_location_property          },
00121   { "tight_limits"       , get_tight_limits_property        },
00122   { "closed"             , get_closed_property              },
00123   { "auto_position"      , get_auto_position_property       },
00124   { "auto_rotation"      , get_auto_rotation_property       },
00125   { "position"           , get_position_property            },
00126   { "auto_ticks"         , get_auto_ticks_property          },
00127   { "axes_reverse"       , get_axes_reverse_property        },
00128   { "view"               , get_view_property                },
00129   { "axes_bounds"        , get_axes_bounds_property         },
00130   { "data_bounds"        , get_data_bounds_property         },
00131   { "margins"            , get_margins_property             },
00132   { "tics_color"         , get_tics_color_property          },
00133   { "tics_style"         , get_tics_style_property          },
00134   { "sub_tics"           , get_sub_tics_property            },
00135   { "sub_ticks"          , get_sub_tics_property            },
00136   { "tics_segment"       , get_tics_segment_property        },
00137   { "labels_font_size"   , get_labels_font_size_property    },
00138   { "labels_font_color"  , get_labels_font_color_property   },
00139   { "labels_font_style"  , get_labels_font_style_property   },
00140   { "format_n"           , get_format_n_property            },
00141   { "xtics_coord"        , get_xtics_coord_property         },
00142   { "ytics_coord"        , get_ytics_coord_property         },
00143   { "tics_labels"        , get_tics_labels_property         },
00144   { "box"                , get_box_property                 },
00145   { "grid"               , get_grid_property                },
00146   { "axes_visible"       , get_axes_visible_property        },
00147   { "hiddencolor"        , get_hidden_color_property        },
00148   { "isoview"            , get_isoview_property             },
00149   { "cube_scaling"       , get_cube_scaling_property        },
00150   { "arrow_size"         , get_arrow_size_property          },
00151   { "colored"            , get_colored_property             },
00152   { "data_mapping"       , get_data_mapping_property        },
00153   { "rotation_angles"    , get_rotation_angles_property     },
00154   { "color_mode"         , get_color_mode_property          },
00155   { "color_flag"         , get_color_flag_property          },
00156   { "cdata_mapping"      , get_cdata_mapping_property       },
00157   { "surface_color"      , get_surface_color_property       },
00158   { "triangles"          , get_triangles_property           },
00159   { "z_bounds"           , get_z_bounds_property            },
00160   { "user_data"          , get_user_data_property           },
00161   { "handle_visible"     , get_handle_visible_property      },
00162   { "callback_type"      , get_callback_type_property       },
00163   { "menu_enable"        , get_menu_enable_property         },
00164   { "hidden_axis_color"  , get_hidden_axis_color_property   },
00165   { "x_ticks"            , get_x_ticks_property             },
00166   { "y_ticks"            , get_y_ticks_property             },
00167   { "z_ticks"            , get_z_ticks_property             },
00168   { "viewport"           , get_viewport_property            },
00169   { "info_message"       , get_info_message_property        }
00170 } ;
00171 
00172 /*-----------------------------------------------------------------------------------*/
00173 GetPropertyHashTable * createScilabGetHashTable( void )
00174 {
00175   int i ;
00176   if ( getHashTableCreated )
00177   {
00178     return getHashTable ;
00179   }
00180 
00181   /* create the hash table */
00182   getHashTable = createGetHashTable() ;
00183 
00184   if ( getHashTable == NULL )
00185   {
00186     return NULL ;
00187   }
00188 
00189   /* insert every couple */
00190   for ( i = 0 ; i < NB_PROPERTIES ; i++ )
00191   {
00192     insertGetHashtable( getHashTable, propertyTable[i].key, propertyTable[i].accessor ) ;
00193   }
00194 
00195   getHashTableCreated = TRUE ;
00196 
00197   return getHashTable ;
00198 
00199 }
00200 /*-----------------------------------------------------------------------------------*/
00201 int callGetProperty( sciPointObj * pObj, char * propertyName )
00202 {
00203   getPropertyFunc accessor = searchGetHashtable( getHashTable, propertyName ) ;
00204   if ( accessor == NULL )
00205   {
00206     sciprint( "Unknown property.\n" ) ;
00207     return -1 ;
00208   }
00209   return accessor( pObj ) ;
00210 }
00211 /*-----------------------------------------------------------------------------------*/
00212 void destroyScilabGetHashTable( void )
00213 {
00214   if ( !getHashTableCreated )
00215   {
00216     return ;
00217   }
00218   
00219   destroyGetHashTable( getHashTable ) ;
00220   getHashTableCreated = FALSE ;
00221 }
00222 /*-----------------------------------------------------------------------------------*/
00223 
00224 #undef NB_PROPERTIES

Generated on Sun Mar 4 15:03:51 2007 for Scilab [trunk] by  doxygen 1.5.1