author | zautrix <zautrix> | 2004-06-29 11:59:46 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-06-29 11:59:46 (UTC) |
commit | da43dbdc6c82453228f34766fc74585615cba938 (patch) (unidiff) | |
tree | 16576932cea08bf117b2d0320b0d5f66ee8ad093 /libical/src/libicalss/icalset.h | |
parent | 627489ea2669d3997676bc3cee0f5d0d0c16c4d4 (diff) | |
download | kdepimpi-da43dbdc6c82453228f34766fc74585615cba938.zip kdepimpi-da43dbdc6c82453228f34766fc74585615cba938.tar.gz kdepimpi-da43dbdc6c82453228f34766fc74585615cba938.tar.bz2 |
New lib ical.Some minor changes as well.
Diffstat (limited to 'libical/src/libicalss/icalset.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libical/src/libicalss/icalset.h | 121 |
1 files changed, 97 insertions, 24 deletions
diff --git a/libical/src/libicalss/icalset.h b/libical/src/libicalss/icalset.h index 7b083da..4008c62 100644 --- a/libical/src/libicalss/icalset.h +++ b/libical/src/libicalss/icalset.h | |||
@@ -1,26 +1,28 @@ | |||
1 | /* -*- Mode: C -*- */ | 1 | /* -*- Mode: C -*- */ |
2 | /*====================================================================== | 2 | /** |
3 | FILE: icalset.h | 3 | @file icalset.h |
4 | CREATOR: eric 28 November 1999 | 4 | @author eric 28 November 1999 |
5 | |||
6 | 5 | ||
7 | Icalset is the "base class" for representations of a collection of | 6 | Icalset is the "base class" for representations of a collection of |
8 | iCal components. Derived classes (actually delegatees) include: | 7 | iCal components. Derived classes (actually delegatees) include: |
9 | 8 | ||
10 | icalfileset Store componetns in a single file | 9 | icalfileset Store components in a single file |
11 | icaldirset Store components in multiple files in a directory | 10 | icaldirset Store components in multiple files in a directory |
11 | icalbdbset Store components in a Berkeley DB File | ||
12 | icalheapset Store components on the heap | 12 | icalheapset Store components on the heap |
13 | icalmysqlset Store components in a mysql database. | 13 | icalmysqlset Store components in a mysql database. |
14 | **/ | ||
14 | 15 | ||
16 | /* | ||
15 | $Id$ | 17 | $Id$ |
16 | $Locker$ | 18 | $Locker$ |
17 | 19 | ||
18 | (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org | 20 | (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org |
19 | 21 | ||
20 | This program is free software; you can redistribute it and/or modify | 22 | This program is free software; you can redistribute it and/or modify |
21 | it under the terms of either: | 23 | it under the terms of either: |
22 | 24 | ||
23 | The LGPL as published by the Free Software Foundation, version | 25 | The LGPL as published by the Free Software Foundation, version |
24 | 2.1, available at: http://www.fsf.org/copyleft/lesser.html | 26 | 2.1, available at: http://www.fsf.org/copyleft/lesser.html |
25 | 27 | ||
26 | Or: | 28 | Or: |
@@ -30,82 +32,153 @@ | |||
30 | 32 | ||
31 | The Original Code is eric. The Initial Developer of the Original | 33 | The Original Code is eric. The Initial Developer of the Original |
32 | Code is Eric Busboom | 34 | Code is Eric Busboom |
33 | 35 | ||
34 | 36 | ||
35 | ======================================================================*/ | 37 | ======================================================================*/ |
36 | 38 | ||
37 | #ifndef ICALSET_H | 39 | #ifndef ICALSET_H |
38 | #define ICALSET_H | 40 | #define ICALSET_H |
39 | 41 | ||
40 | #include <limits.h> /* For PATH_MAX */ | 42 | #include <limits.h> /* For PATH_MAX */ |
41 | #include "ical.h" | 43 | #include "ical.h" |
42 | #include "icalerror.h" | 44 | #include "icalgauge.h" |
43 | 45 | ||
44 | #ifdef PATH_MAX | 46 | #ifdef PATH_MAX |
45 | #define ICAL_PATH_MAX PATH_MAX | 47 | #define ICAL_PATH_MAX PATH_MAX |
46 | #else | 48 | #else |
47 | #define ICAL_PATH_MAX 1024 | 49 | #define ICAL_PATH_MAX 1024 |
48 | #endif | 50 | #endif |
49 | 51 | ||
50 | 52 | ||
51 | 53 | typedef struct icalset_impl icalset; | |
52 | |||
53 | typedef void icalset; | ||
54 | 54 | ||
55 | typedef enum icalset_kind { | 55 | typedef enum icalset_kind { |
56 | ICAL_FILE_SET, | 56 | ICAL_FILE_SET, |
57 | ICAL_DIR_SET, | 57 | ICAL_DIR_SET, |
58 | ICAL_HEAP_SET, | 58 | ICAL_BDB_SET |
59 | ICAL_MYSQL_SET, | ||
60 | ICAL_CAP_SET | ||
61 | } icalset_kind; | 59 | } icalset_kind; |
62 | 60 | ||
61 | typedef struct icalsetiter | ||
62 | { | ||
63 | icalcompiter iter; /* icalcomponent_kind, pvl_elem iter */ | ||
64 | icalgauge* gauge; | ||
65 | icalrecur_iterator* ritr; /*the last iterator*/ | ||
66 | icalcomponent* last_component; /*the pending recurring component to be processed */ | ||
67 | const char* tzid; /* the calendar's timezone id */ | ||
68 | } icalsetiter; | ||
69 | |||
70 | struct icalset_impl { | ||
71 | icalset_kind kind; | ||
72 | int size; | ||
73 | char *dsn; | ||
74 | icalset* (*init)(icalset* set, const char *dsn, void *options); | ||
75 | void (*free)(icalset* set); | ||
76 | const char* (*path)(icalset* set); | ||
77 | void (*mark)(icalset* set); | ||
78 | icalerrorenum (*commit)(icalset* set); | ||
79 | icalerrorenum (*add_component)(icalset* set, icalcomponent* comp); | ||
80 | icalerrorenum (*remove_component)(icalset* set, icalcomponent* comp); | ||
81 | int (*count_components)(icalset* set, | ||
82 | icalcomponent_kind kind); | ||
83 | icalerrorenum (*select)(icalset* set, icalgauge* gauge); | ||
84 | void (*clear)(icalset* set); | ||
85 | icalcomponent* (*fetch)(icalset* set, const char* uid); | ||
86 | icalcomponent* (*fetch_match)(icalset* set, icalcomponent *comp); | ||
87 | int (*has_uid)(icalset* set, const char* uid); | ||
88 | icalerrorenum (*modify)(icalset* set, icalcomponent *old, | ||
89 | icalcomponent *newc); | ||
90 | icalcomponent* (*get_current_component)(icalset* set); | ||
91 | icalcomponent* (*get_first_component)(icalset* set); | ||
92 | icalcomponent* (*get_next_component)(icalset* set); | ||
93 | icalsetiter (*icalset_begin_component)(icalset* set, | ||
94 | icalcomponent_kind kind, icalgauge* gauge); | ||
95 | icalcomponent* (*icalsetiter_to_next)(icalset* set, icalsetiter* i); | ||
96 | icalcomponent* (*icalsetiter_to_prior)(icalset* set, icalsetiter* i); | ||
97 | }; | ||
98 | |||
99 | /** @brief Register a new derived class */ | ||
100 | int icalset_register_class(icalset *set); | ||
101 | |||
102 | |||
103 | /** @brief Generic icalset constructor | ||
104 | * | ||
105 | * @param kind The type of icalset to create | ||
106 | * @param dsn Data Source Name - usually a pathname or DB handle | ||
107 | * @param options Any implementation specific options | ||
108 | * | ||
109 | * @return A valid icalset reference or NULL if error. | ||
110 | * | ||
111 | * This creates any of the icalset types available. | ||
112 | */ | ||
113 | |||
114 | icalset* icalset_new(icalset_kind kind, const char* dsn, void* options); | ||
63 | 115 | ||
64 | /* Create a specific derived type of set */ | ||
65 | icalset* icalset_new_file(const char* path); | 116 | icalset* icalset_new_file(const char* path); |
117 | icalset* icalset_new_file_reader(const char* path); | ||
118 | icalset* icalset_new_file_writer(const char* path); | ||
119 | |||
66 | icalset* icalset_new_dir(const char* path); | 120 | icalset* icalset_new_dir(const char* path); |
67 | icalset* icalset_new_heap(void); | 121 | icalset* icalset_new_file_reader(const char* path); |
68 | icalset* icalset_new_mysql(const char* path); | 122 | icalset* icalset_new_file_writer(const char* path); |
69 | /*icalset* icalset_new_cap(icalcstp* cstp);*/ | ||
70 | 123 | ||
71 | void icalset_free(icalset* set); | 124 | void icalset_free(icalset* set); |
72 | 125 | ||
73 | const char* icalset_path(icalset* set); | 126 | const char* icalset_path(icalset* set); |
74 | 127 | ||
75 | /* Mark the cluster as changed, so it will be written to disk when it | 128 | /** Mark the cluster as changed, so it will be written to disk when it |
76 | is freed. Commit writes to disk immediately*/ | 129 | is freed. **/ |
77 | void icalset_mark(icalset* set); | 130 | void icalset_mark(icalset* set); |
131 | |||
132 | /** Write changes to disk immediately */ | ||
78 | icalerrorenum icalset_commit(icalset* set); | 133 | icalerrorenum icalset_commit(icalset* set); |
79 | 134 | ||
80 | icalerrorenum icalset_add_component(icalset* set, icalcomponent* comp); | 135 | icalerrorenum icalset_add_component(icalset* set, icalcomponent* comp); |
81 | icalerrorenum icalset_remove_component(icalset* set, icalcomponent* comp); | 136 | icalerrorenum icalset_remove_component(icalset* set, icalcomponent* comp); |
82 | 137 | ||
83 | int icalset_count_components(icalset* set, | 138 | int icalset_count_components(icalset* set, |
84 | icalcomponent_kind kind); | 139 | icalcomponent_kind kind); |
85 | 140 | ||
86 | /* Restrict the component returned by icalset_first, _next to those | 141 | /** Restrict the component returned by icalset_first, _next to those |
87 | that pass the gauge. _clear removes the gauge. */ | 142 | that pass the gauge. */ |
88 | icalerrorenum icalset_select(icalset* set, icalcomponent* gauge); | 143 | icalerrorenum icalset_select(icalset* set, icalgauge* gauge); |
144 | |||
145 | /** Clears the gauge defined by icalset_select() */ | ||
89 | void icalset_clear_select(icalset* set); | 146 | void icalset_clear_select(icalset* set); |
90 | 147 | ||
91 | /* Get a component by uid */ | 148 | /** Get a component by uid */ |
92 | icalcomponent* icalset_fetch(icalset* set, const char* uid); | 149 | icalcomponent* icalset_fetch(icalset* set, const char* uid); |
150 | |||
93 | int icalset_has_uid(icalset* set, const char* uid); | 151 | int icalset_has_uid(icalset* set, const char* uid); |
94 | icalcomponent* icalset_fetch_match(icalset* set, icalcomponent *c); | 152 | icalcomponent* icalset_fetch_match(icalset* set, icalcomponent *c); |
95 | 153 | ||
96 | /* Modify components according to the MODIFY method of CAP. Works on | 154 | /** Modify components according to the MODIFY method of CAP. Works on |
97 | the currently selected components. */ | 155 | the currently selected components. */ |
98 | icalerrorenum icalset_modify(icalset* set, icalcomponent *oldc, | 156 | icalerrorenum icalset_modify(icalset* set, icalcomponent *oldc, |
99 | icalcomponent *newc); | 157 | icalcomponent *newc); |
100 | 158 | ||
101 | /* Iterate through the components. If a guage has been defined, these | 159 | /** Iterate through the components. If a guage has been defined, these |
102 | will skip over components that do not pass the gauge */ | 160 | will skip over components that do not pass the gauge */ |
103 | 161 | ||
104 | icalcomponent* icalset_get_current_component(icalset* set); | 162 | icalcomponent* icalset_get_current_component(icalset* set); |
105 | icalcomponent* icalset_get_first_component(icalset* set); | 163 | icalcomponent* icalset_get_first_component(icalset* set); |
106 | icalcomponent* icalset_get_next_component(icalset* set); | 164 | icalcomponent* icalset_get_next_component(icalset* set); |
107 | 165 | ||
166 | /** External Iterator with gauge - for thread safety */ | ||
167 | extern icalsetiter icalsetiter_null; | ||
168 | |||
169 | icalsetiter icalset_begin_component(icalset* set, | ||
170 | icalcomponent_kind kind, icalgauge* gauge); | ||
171 | |||
172 | /** Default _next, _prior, _deref for subclasses that use single cluster */ | ||
173 | icalcomponent* icalsetiter_next(icalsetiter* i); | ||
174 | icalcomponent* icalsetiter_prior(icalsetiter* i); | ||
175 | icalcomponent* icalsetiter_deref(icalsetiter* i); | ||
176 | |||
177 | /** for subclasses that use multiple clusters that require specialized cluster traversal */ | ||
178 | icalcomponent* icalsetiter_to_next(icalset* set, icalsetiter* i); | ||
179 | icalcomponent* icalsetiter_to_prior(icalset* set, icalsetiter* i); | ||
180 | |||
108 | #endif /* !ICALSET_H */ | 181 | #endif /* !ICALSET_H */ |
109 | 182 | ||
110 | 183 | ||
111 | 184 | ||