Add license files and headers
[navit-package] / navit / item.h
1 /**
2  * Navit, a modular navigation system.
3  * Copyright (C) 2005-2008 Navit Team
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public License
7  * version 2 as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this program; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA  02110-1301, USA.
18  */
19
20 #ifndef NAVIT_ITEM_H
21 #define NAVIT_ITEM_H
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 enum item_type {
28 #define ITEM2(x,y) type_##y=x,
29 #define ITEM(x) type_##x,
30 #include "item_def.h"
31 #undef ITEM2
32 #undef ITEM
33 };
34
35 #include "attr.h"
36
37 #define item_is_equal_id(a,b) ((a).id_hi == (b).id_hi && (a).id_lo == (b).id_lo)
38 #define item_is_equal(a,b) (item_is_equal_id(a,b) && (a).map == (b).map)
39
40 struct coord;
41
42 struct item_methods {
43         void (*item_coord_rewind)(void *priv_data);
44         int (*item_coord_get)(void *priv_data, struct coord *c, int count);
45         void (*item_attr_rewind)(void *priv_data);
46         int (*item_attr_get)(void *priv_data, enum attr_type attr_type, struct attr *attr);
47         int (*item_coord_is_segment)(void *priv_data);
48 };
49
50 struct item {
51         enum item_type type;
52         int id_hi;
53         int id_lo;
54         struct map *map;
55         struct item_methods *meth;      
56         void *priv_data;
57 };
58
59 /* prototypes */
60 enum attr_type;
61 enum item_type;
62 struct attr;
63 struct coord;
64 struct item;
65 struct item_hash;
66 void item_coord_rewind(struct item *it);
67 int item_coord_get(struct item *it, struct coord *c, int count);
68 /* does the next returned coordinate mark a segment */
69 int item_coord_is_segment(struct item *it);
70 void item_attr_rewind(struct item *it);
71 int item_attr_get(struct item *it, enum attr_type attr_type, struct attr *attr);
72 struct item *item_new(char *type, int zoom);
73 enum item_type item_from_name(const char *name);
74 char *item_to_name(enum item_type item);
75 struct item_hash *item_hash_new(void);
76 void item_hash_insert(struct item_hash *h, struct item *item, void *val);
77 int item_hash_remove(struct item_hash *h, struct item *item);
78 void *item_hash_lookup(struct item_hash *h, struct item *item);
79 void item_hash_destroy(struct item_hash *h);
80 /* end of prototypes */
81
82
83 #ifdef __cplusplus
84 }
85 /* __cplusplus */
86 #endif
87
88 /* NAVIT_ITEM_H */
89 #endif