Changeset 151


Ignore:
Timestamp:
Oct 17, 2009, 3:34:48 PM (5 years ago)
Author:
simon
Message:

Make cfgRules private

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/Makefile.am

    r149 r151  
    4848    textpath.h \ 
    4949    osm05.h \ 
     50    ruleset.h \ 
    5051    mlib.h 
    5152 
     
    5657    memphis-rule-set.h \ 
    5758    memphis-map.h \ 
    58     memphis-renderer.h \ 
    59     ruleset.h 
     59    memphis-renderer.h 
    6060 
    6161libmemphis_0_1_la_LIBADD = $(DEPS_LIBS) 
  • trunk/src/main.c

    r149 r151  
    168168    ruleset = memphis_rule_set_new (); 
    169169    memphis_rule_set_load_from_file (ruleset, opts->cfgfn); 
    170     if (ruleset->ruleset == NULL) 
    171         return(-1); 
     170    //if (ruleset->ruleset == NULL) 
     171    //    return(-1); 
    172172 
    173173    osm = memphis_map_new (); 
  • trunk/src/memphis-renderer.c

    r149 r151  
    124124 
    125125  osm = memphis_map_get_osmFile (priv->map); 
    126  
    127   if (!(priv->rules->ruleset && osm != NULL)) { 
     126  ruleset = memphis_rule_set_get_cfgRules (priv->rules); 
     127 
     128  if (ruleset == NULL || osm == NULL) { 
    128129    if (priv->debug_level > 0) 
    129130      g_fprintf (stdout, " No map and/or rules data: Draw nothing\n"); 
     
    137138      MEMPHIS_RENDERER_MAX_ZOOM_LEVEL); 
    138139 
    139   ruleset = priv->rules->ruleset; 
    140140  min = coord2xy (osm->minlat, osm->minlon, zoom_level, priv->resolution); 
    141141  max = coord2xy (osm->maxlat, osm->maxlon, zoom_level, priv->resolution); 
     
    196196 
    197197  osm = memphis_map_get_osmFile (priv->map); 
    198   ruleset = priv->rules->ruleset; 
    199  
    200   if (!(priv->rules->ruleset && osm)) { 
     198  ruleset = memphis_rule_set_get_cfgRules (priv->rules); 
     199 
     200  if (ruleset == NULL || osm == NULL) { 
    201201    if (priv->debug_level > 0) 
    202202      g_fprintf (stdout, " No map and/or rules data: Draw nothing\n"); 
     
    901901  int layer; 
    902902  MemphisRendererPrivate *p = info->priv; 
    903   cfgRules *ruleset = p->rules->ruleset; 
     903  cfgRules *ruleset = memphis_rule_set_get_cfgRules (p->rules); 
    904904 
    905905  if (p->debug_level > 1) 
  • trunk/src/memphis-rule-set.c

    r142 r151  
    2020#include <string.h> 
    2121#include "mlib.h" 
     22#include "ruleset.h" 
     23#include "memphis-private.h" 
    2224#include "memphis-rule-set.h" 
    2325#include "memphis-data-pool.h" 
     
    3739struct _MemphisRuleSetPrivate { 
    3840  gint8 debug_level; 
     41  cfgRules *ruleset; 
    3942}; 
    4043 
     
    7477{ 
    7578  MemphisRuleSet *self = MEMPHIS_RULE_SET (object); 
    76  
    77   if (self->ruleset != NULL) 
    78     rulesetFree(self->ruleset); 
     79  MemphisRuleSetPrivate *priv = MEMPHIS_RULE_SET_GET_PRIVATE (self); 
     80 
     81  if (priv->ruleset != NULL) 
     82    rulesetFree(priv->ruleset); 
    7983   
    8084  G_OBJECT_CLASS (memphis_rule_set_parent_class)->finalize (object); 
     
    114118{ 
    115119  MemphisRuleSetPrivate *priv = MEMPHIS_RULE_SET_GET_PRIVATE (self); 
    116   self->ruleset = NULL; 
     120  priv->ruleset = NULL; 
    117121  priv->debug_level = 1; 
    118122} 
     
    130134 
    131135  MemphisRuleSetPrivate *priv = MEMPHIS_RULE_SET_GET_PRIVATE (rules); 
    132   if (rules->ruleset != NULL) 
    133     rulesetFree (rules->ruleset); 
    134  
    135   rules->ruleset = rulesetRead (filename, priv->debug_level); 
     136  if (priv->ruleset != NULL) 
     137    rulesetFree (priv->ruleset); 
     138 
     139  priv->ruleset = rulesetRead (filename, priv->debug_level); 
    136140} 
    137141 
     
    144148 
    145149  MemphisRuleSetPrivate *priv = MEMPHIS_RULE_SET_GET_PRIVATE (rules); 
    146   if (rules->ruleset != NULL) 
    147     rulesetFree (rules->ruleset); 
    148  
    149   rules->ruleset = rulesetRead_from_buffer (data, size, priv->debug_level); 
     150  if (priv->ruleset != NULL) 
     151    rulesetFree (priv->ruleset); 
     152 
     153  priv->ruleset = rulesetRead_from_buffer (data, size, priv->debug_level); 
    150154} 
    151155 
     
    181185    guint16 r, guint16 g, guint16 b) 
    182186{ 
    183   self->ruleset->background[0] = (gint16) r; 
    184   self->ruleset->background[1] = (gint16) g; 
    185   self->ruleset->background[2] = (gint16) b; 
     187  MemphisRuleSetPrivate *priv = MEMPHIS_RULE_SET_GET_PRIVATE (self); 
     188 
     189  priv->ruleset->background[0] = (gint16) r; 
     190  priv->ruleset->background[1] = (gint16) g; 
     191  priv->ruleset->background[2] = (gint16) b; 
    186192} 
    187193 
     
    190196    guint16 *r, guint16 *g, guint16 *b) 
    191197{ 
    192   *r = (guint16) self->ruleset->background[0]; 
    193   *g = (guint16) self->ruleset->background[1]; 
    194   *b = (guint16) self->ruleset->background[2]; 
     198  MemphisRuleSetPrivate *priv = MEMPHIS_RULE_SET_GET_PRIVATE (self); 
     199 
     200  *r = (guint16) priv->ruleset->background[0]; 
     201  *g = (guint16) priv->ruleset->background[1]; 
     202  *b = (guint16) priv->ruleset->background[2]; 
    195203} 
    196204 
     
    200208  g_return_val_if_fail (MEMPHIS_IS_RULE_SET (self), NULL); 
    201209 
     210  MemphisRuleSetPrivate *priv = MEMPHIS_RULE_SET_GET_PRIVATE (self); 
     211 
    202212  GList *list = NULL; 
    203   cfgRule *curr = self->ruleset->rule; 
     213  cfgRule *curr = priv->ruleset->rule; 
    204214  while (curr != NULL) 
    205215   { 
     
    443453  g_return_val_if_fail (MEMPHIS_IS_RULE_SET (self) && id != NULL, NULL); 
    444454 
     455  MemphisRuleSetPrivate *priv = MEMPHIS_RULE_SET_GET_PRIVATE (self); 
     456 
    445457  gchar **tmp = g_strsplit (id, ":", -1); 
    446458  gchar **keys = g_strsplit (tmp[0], "|", -1); 
     
    448460  g_strfreev (tmp); 
    449461 
    450   cfgRule *res = search_rule (self->ruleset->rule, keys, values); 
     462  cfgRule *res = search_rule (priv->ruleset->rule, keys, values); 
    451463 
    452464  g_strfreev (keys); 
     
    464476  g_return_if_fail (MEMPHIS_IS_RULE_SET (self) && MEMPHIS_IS_RULE (rule)); 
    465477 
    466   cfgRule *res = search_rule (self->ruleset->rule, rule->keys, rule->values); 
     478  MemphisRuleSetPrivate *priv = MEMPHIS_RULE_SET_GET_PRIVATE (self); 
     479  cfgRule *res = search_rule (priv->ruleset->rule, rule->keys, rule->values); 
    467480  cfgDraw *drw, *tmp; 
    468481 
     
    484497    { 
    485498      /* Append cfgRule at last position */ 
    486       cfgRule *curr = self->ruleset->rule; 
     499      cfgRule *curr = priv->ruleset->rule; 
    487500      while (curr->next != NULL) 
    488501        curr = curr->next; 
     
    491504 
    492505      curr->next = new; 
    493       self->ruleset->cntRule++; 
     506      priv->ruleset->cntRule++; 
    494507    } 
    495508} 
     
    499512{ 
    500513  g_return_val_if_fail (MEMPHIS_IS_RULE_SET (self) && id != NULL, FALSE); 
     514 
     515  MemphisRuleSetPrivate *priv = MEMPHIS_RULE_SET_GET_PRIVATE (self); 
    501516 
    502517  gchar **tmp = g_strsplit (id, ":", -1); 
     
    511526  gint num_keys = g_strv_length (keys); 
    512527  gint num_values = g_strv_length (values); 
    513   cfgRule *curr = self->ruleset->rule; 
     528  cfgRule *curr = priv->ruleset->rule; 
    514529  cfgRule *prev = NULL; 
    515530 
     
    560575  prev->next = curr->next; 
    561576  cfgRuleFree (curr); 
    562   self->ruleset->cntRule--; 
     577  priv->ruleset->cntRule--; 
    563578  return TRUE; 
    564579} 
     580 
     581/* private shared functions */ 
     582 
     583cfgRules * 
     584memphis_rule_set_get_cfgRules (MemphisRuleSet *self) 
     585{ 
     586  g_assert (self != NULL); 
     587 
     588  MemphisRuleSetPrivate *priv = MEMPHIS_RULE_SET_GET_PRIVATE (self); 
     589 
     590  return priv->ruleset; 
     591} 
  • trunk/src/memphis-rule-set.h

    r142 r151  
    2222 
    2323#include <glib-object.h> 
    24 #include "ruleset.h" 
    2524#include "memphis-rule.h" 
    2625 
     
    4645typedef struct { 
    4746  GObject parent; 
    48   cfgRules *ruleset; 
    4947} MemphisRuleSet; 
    5048 
Note: See TracChangeset for help on using the changeset viewer.