summaryrefslogtreecommitdiffabout
path: root/libical/src/libicalss/icalset.h
Unidiff
Diffstat (limited to 'libical/src/libicalss/icalset.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libical/src/libicalss/icalset.h121
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,20 +1,22 @@
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
@@ -36,76 +38,147 @@
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 53typedef struct icalset_impl icalset;
52
53typedef void icalset;
54 54
55typedef enum icalset_kind { 55typedef 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
61typedef 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
70struct 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 */
100int 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
114icalset* icalset_new(icalset_kind kind, const char* dsn, void* options);
63 115
64/* Create a specific derived type of set */
65icalset* icalset_new_file(const char* path); 116icalset* icalset_new_file(const char* path);
117icalset* icalset_new_file_reader(const char* path);
118icalset* icalset_new_file_writer(const char* path);
119
66icalset* icalset_new_dir(const char* path); 120icalset* icalset_new_dir(const char* path);
67icalset* icalset_new_heap(void); 121icalset* icalset_new_file_reader(const char* path);
68icalset* icalset_new_mysql(const char* path); 122icalset* icalset_new_file_writer(const char* path);
69/*icalset* icalset_new_cap(icalcstp* cstp);*/
70 123
71void icalset_free(icalset* set); 124void icalset_free(icalset* set);
72 125
73const char* icalset_path(icalset* set); 126const 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. **/
77void icalset_mark(icalset* set); 130void icalset_mark(icalset* set);
131
132/** Write changes to disk immediately */
78icalerrorenum icalset_commit(icalset* set); 133icalerrorenum icalset_commit(icalset* set);
79 134
80icalerrorenum icalset_add_component(icalset* set, icalcomponent* comp); 135icalerrorenum icalset_add_component(icalset* set, icalcomponent* comp);
81icalerrorenum icalset_remove_component(icalset* set, icalcomponent* comp); 136icalerrorenum icalset_remove_component(icalset* set, icalcomponent* comp);
82 137
83int icalset_count_components(icalset* set, 138int 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. */
88icalerrorenum icalset_select(icalset* set, icalcomponent* gauge); 143icalerrorenum icalset_select(icalset* set, icalgauge* gauge);
144
145/** Clears the gauge defined by icalset_select() */
89void icalset_clear_select(icalset* set); 146void icalset_clear_select(icalset* set);
90 147
91/* Get a component by uid */ 148/** Get a component by uid */
92icalcomponent* icalset_fetch(icalset* set, const char* uid); 149icalcomponent* icalset_fetch(icalset* set, const char* uid);
150
93int icalset_has_uid(icalset* set, const char* uid); 151int icalset_has_uid(icalset* set, const char* uid);
94icalcomponent* icalset_fetch_match(icalset* set, icalcomponent *c); 152icalcomponent* 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. */
98icalerrorenum icalset_modify(icalset* set, icalcomponent *oldc, 156icalerrorenum 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
104icalcomponent* icalset_get_current_component(icalset* set); 162icalcomponent* icalset_get_current_component(icalset* set);
105icalcomponent* icalset_get_first_component(icalset* set); 163icalcomponent* icalset_get_first_component(icalset* set);
106icalcomponent* icalset_get_next_component(icalset* set); 164icalcomponent* icalset_get_next_component(icalset* set);
107 165
166/** External Iterator with gauge - for thread safety */
167extern icalsetiter icalsetiter_null;
168
169icalsetiter icalset_begin_component(icalset* set,
170 icalcomponent_kind kind, icalgauge* gauge);
171
172/** Default _next, _prior, _deref for subclasses that use single cluster */
173icalcomponent* icalsetiter_next(icalsetiter* i);
174icalcomponent* icalsetiter_prior(icalsetiter* i);
175icalcomponent* icalsetiter_deref(icalsetiter* i);
176
177/** for subclasses that use multiple clusters that require specialized cluster traversal */
178icalcomponent* icalsetiter_to_next(icalset* set, icalsetiter* i);
179icalcomponent* icalsetiter_to_prior(icalset* set, icalsetiter* i);
180
108#endif /* !ICALSET_H */ 181#endif /* !ICALSET_H */
109 182
110 183
111 184