struct layout *layout;
struct layer *layer;
struct map *map;
+ struct mapset *mapset;
struct log *log;
struct route *route;
struct navigation *navigation;
ATTR(directed)
ATTR(radius)
ATTR(text_size)
+ATTR(level)
ATTR2(0x00028000,type_boolean_begin)
/* boolean */
ATTR(overwrite)
ATTR(icon)
ATTR(image)
ATTR(arrows)
+ATTR(mapset)
ATTR2(0x0008ffff,type_object_end)
ATTR2(0x00090000,type_coord_begin)
ATTR2(0x0009ffff,type_coord_end)
if (!PyArg_ParseTuple(args, "ss:navit.map", &type, &filename))
return NULL;
ret=PyObject_NEW(mapObject, &map_Type);
- ret->m=map_new(NULL);
+ ret->m=map_new(NULL,NULL);
return (PyObject *)ret;
}
if (!PyArg_ParseTuple(args, ":navit.mapset"))
return NULL;
ret=PyObject_NEW(mapsetObject, &mapset_Type);
- ret->ms=mapset_new();
+ ret->ms=mapset_new(NULL,NULL);
return (PyObject *)ret;
}
#include <time.h>
#include <glib.h>
#include "file.h"
+#include "item.h"
#include "debug.h"
int debug_level=0,segv_level=0;
+static int dummy;
static GHashTable *debug_hash;
static char *gdb_program;
}
}
+struct debug *
+debug_new(struct attr *parent, struct attr **attrs)
+{
+ struct attr *name,*level;
+ name=attr_search(attrs, NULL, attr_name);
+ level=attr_search(attrs, NULL, attr_level);
+ if (!name || !level)
+ return NULL;
+ debug_level_set(name->u.str, level->u.num);
+ return (struct debug *)&dummy;
+}
+
+
int
debug_level_get(const char *name)
{
#define dbg_assert(expr) ((expr) ? (void) 0 : debug_assert_fail(dbg_module,strlen(dbg_module),__PRETTY_FUNCTION__, strlen(__PRETTY_FUNCTION__),__FILE__,__LINE__,dbg_str1(expr)))
/* prototypes */
+struct attr;
void debug_init(const char *program_name);
void debug_level_set(const char *name, int level);
int debug_level_get(const char *name);
+struct debug *debug_new(struct attr *parent, struct attr **attrs);
void debug_vprintf(int level, const char *module, const int mlen, const char *function, const int flen, int prefix, const char *fmt, va_list ap);
void debug_printf(int level, const char *module, const int mlen, const char *function, const int flen, int prefix, const char *fmt, ...);
void debug_assert_fail(char *module, const int mlen,const char *function, const int flen, char *file, int line, char *expr);
* @return The opened map or NULL on failure
*/
struct map *
-map_new(struct attr **attrs)
+map_new(struct attr *parent, struct attr **attrs)
{
struct map *m;
struct map_priv *(*maptype_new)(struct map_methods *meth, struct attr **attrs);
struct map_search;
struct map_selection;
struct pcoord;
-struct map *map_new(struct attr **attrs);
+struct map *map_new(struct attr *parent, struct attr **attrs);
int map_get_attr(struct map *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter);
int map_set_attr(struct map *this_, struct attr *attr);
void map_add_callback(struct map *this_, struct callback *cb);
*
* @return The new mapset
*/
-struct mapset *mapset_new(void)
+struct mapset *mapset_new(struct attr *parent, struct attr **attrs)
{
struct mapset *ms;
return ms;
}
+
/**
* @brief Adds a map to a mapset
*
* @param ms The mapset to add the map to
* @param m The map to be added
*/
-void mapset_add(struct mapset *ms, struct map *m)
+int
+mapset_add_attr(struct mapset *ms, struct attr *attr)
{
- ms->maps=g_list_append(ms->maps, m);
+ switch (attr->type) {
+ case attr_map:
+ ms->maps=g_list_append(ms->maps, attr->u.map);
+ return 1;
+ default:
+ return 0;
+ }
}
#if 0
struct mapset;
struct mapset_handle;
struct mapset_search;
-struct mapset *mapset_new(void);
-void mapset_add(struct mapset *ms, struct map *m);
+struct mapset *mapset_new(struct attr *parent, struct attr **attrs);
+int mapset_add_attr(struct mapset *ms, struct attr *attr);
void mapset_destroy(struct mapset *ms);
struct mapset_handle *mapset_open(struct mapset *ms);
struct map *mapset_next(struct mapset_handle *msh, int active);
navigation_get_map(struct navigation *this_)
{
if (! this_->map)
- this_->map=map_new((struct attr*[]){
+ this_->map=map_new(NULL, (struct attr*[]){
&(struct attr){attr_type,{"navigation"}},
&(struct attr){attr_navigation,.u.navigation=this_},
&(struct attr){attr_data,{""}},
navit_add_bookmarks_from_file(struct navit *this_)
{
char *bookmark_file = navit_get_bookmark_file(FALSE);
+ struct attr parent={attr_navit, .u.navit=this_};
struct attr type={attr_type, {"textfile"}}, data={attr_data, {bookmark_file}};
struct attr *attrs[]={&type, &data, NULL};
- this_->bookmark=map_new(attrs);
+ this_->bookmark=map_new(&parent, attrs);
g_free(bookmark_file);
}
navit_add_former_destinations_from_file(struct navit *this_)
{
char *destination_file = navit_get_destination_file(FALSE);
+ struct attr parent={attr_navit, .u.navit=this_};
struct attr type={attr_type, {"textfile"}}, data={attr_data, {destination_file}};
struct attr *attrs[]={&type, &data, NULL};
- this_->former_destination=map_new(attrs);
+ this_->former_destination=map_new(&parent, attrs);
g_free(destination_file);
}
ms=this_->mapsets->data;
if (this_->route) {
if ((map=route_get_map(this_->route)))
- mapset_add(ms, map);
+ mapset_add_attr(ms, (struct attr*[]){
+ &(struct attr){attr_map,{map}},
+ NULL});
if ((map=route_get_graph_map(this_->route))) {
- mapset_add(ms, map);
+ mapset_add_attr(ms, (struct attr*[]){
+ &(struct attr){attr_map,{map}},
+ NULL});
map_set_attr(map, &(struct attr ){attr_active,.u.num=0});
}
route_set_mapset(this_->route, ms);
}
if (this_->navigation) {
if ((map=navigation_get_map(this_->navigation))) {
- mapset_add(ms, map);
+ mapset_add_attr(ms, (struct attr*[]){
+ &(struct attr){attr_map,{map}},
+ NULL});
map_set_attr(map, &(struct attr ){attr_active,.u.num=0});
}
}
if (this_->tracking) {
if ((map=tracking_get_map(this_->tracking))) {
- mapset_add(ms, map);
+ mapset_add_attr(ms, (struct attr*[]){
+ &(struct attr){attr_map,{map}},
+ NULL});
map_set_attr(map, &(struct attr ){attr_active,.u.num=0});
}
}
case attr_route:
this_->route=attr->u.route;
break;
+ case attr_mapset:
+ this_->mapsets = g_list_append(this_->mapsets, attr->u.mapset);
+ break;
case attr_navigation:
this_->navigation=attr->u.navigation;
break;
route_get_map_helper(struct route *this_, struct map **map, char *type, char *description)
{
if (! *map)
- *map=map_new((struct attr*[]){
+ *map=map_new(NULL, (struct attr*[]){
&(struct attr){attr_type,{type}},
&(struct attr){attr_route,.u.route=this_},
&(struct attr){attr_data,{""}},
tracking_get_map(struct tracking *this_)
{
if (! this_->map)
- this_->map=map_new((struct attr*[]){
+ this_->map=map_new(NULL, (struct attr*[]){
&(struct attr){attr_type,{"tracking"}},
&(struct attr){attr_trackingo,.u.tracking=this_},
&(struct attr){attr_data,{""}},
}
static int
-xmlconfig_debug(struct xmlstate *state)
-{
- const char *name,*level;
- name=find_attribute(state, "name", 1);
- if (! name)
- return 0;
- level=find_attribute(state, "level", 1);
- if (! level)
- return 0;
- debug_level_set(name, convert_number(level));
- return 1;
-}
-
-static int
xmlconfig_window_items(struct xmlstate *state)
{
int distance=-1;
static int
-xmlconfig_navigation(struct xmlstate *state)
-{
- struct attr **attrs;
- struct attr navigation_attr;
-
- attrs=convert_to_attrs(state,NULL);
- state->element_attr.u.data = navigation_new(attrs);
- if (! state->element_attr.u.data) {
- dbg(0,"Failed to create navigation object\n");
- return 0;
- }
- navigation_attr.type=attr_navigation;
- navigation_attr.u.navigation=state->element_attr.u.data;
- return navit_add_attr(state->parent->element_attr.u.data, &navigation_attr);
-}
-
-static int
-xmlconfig_osd(struct xmlstate *state)
-{
- struct attr **attrs;
- const char *type=find_attribute(state, "type", 1);
- if (! type)
- return 0;
- attrs=convert_to_attrs(state,NULL);
- state->element_attr.u.data = osd_new(state->parent->element_attr.u.data, type, attrs);
- return 1;
-}
-
-static int
xmlconfig_announce(struct xmlstate *state)
{
const char *type,*value;
return 1;
}
-static int
-xmlconfig_mapset(struct xmlstate *state)
-{
- state->element_attr.u.data = mapset_new();
- if (! state->element_attr.u.data)
- return 0;
- navit_add_mapset(state->parent->element_attr.u.data, state->element_attr.u.data);
-
- return 1;
-}
-
-static int
-xmlconfig_map(struct xmlstate *state)
-{
- struct attr **attrs;
- attrs=convert_to_attrs(state,NULL);
- state->element_attr.u.data = map_new(attrs);
- if (! state->element_attr.u.data)
- return 0;
- mapset_add(state->parent->element_attr.u.data, state->element_attr.u.data);
-
- return 1;
-}
-
#define NEW(x) (void *(*)(struct attr *, struct attr **))(x)
#define ADD(x) (int (*)(void *, struct attr *attr))(x)
#define INIT(x) (int (*)(void *))(x)
void (*destroy)(void *);
} elements[] = {
{ "config", NULL, xmlconfig_config},
- { "debug", "config", xmlconfig_debug},
- { "mapset", "navit", xmlconfig_mapset},
- { "map", "mapset", xmlconfig_map},
- { "navigation", "navit", xmlconfig_navigation},
- { "osd", "navit", xmlconfig_osd},
{ "announce", "navigation", xmlconfig_announce},
{ "speech", "navit", xmlconfig_speech},
{ "tracking", "navit", xmlconfig_tracking},
{ "route", "navit", xmlconfig_route},
{ "speed", "route", xmlconfig_speed},
+ { "mapset", "navit", NULL, NEW(mapset_new), ADD(mapset_add_attr)},
+ { "map", "mapset", NULL, NEW(map_new)},
+ { "debug", "config", NULL, NEW(debug_new)},
+ { "osd", "navit", NULL, NEW(osd_new)},
+ { "navigation", "navit", NULL, NEW(navigation_new)},
{ "navit", "config", NULL, NEW(navit_new), ADD(navit_add_attr), INIT(navit_init), DESTROY(navit_destroy)},
{ "graphics", "navit", NULL, NEW(graphics_new)},
{ "gui", "navit", NULL, NEW(gui_new)},