blob: 38761af4c65c3c80c2cee4ed7c210d9db4fd9815 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
#include "icalspanlist_cxx.h"
#include <exception>
/** @brief Construct an ICalSpanList from an icalset
@param set The icalset containing the VEVENTS
@param start Designated start of the spanlist
@param end Designated end of the spanlist
*/
ICalSpanList::ICalSpanList(icalset *set, icaltimetype start, icaltimetype end) throw(icalerrorenum)
{
data = icalspanlist_new(set, start, end);
if (!data) throw icalerrno;
};
/** @brief Constructor
@param comp A valid icalcomponent with a VFREEBUSY section
*/
ICalSpanList::ICalSpanList(icalcomponent *comp) throw(icalerrorenum)
{
data = icalspanlist_from_vfreebusy(comp);
if (!data) throw icalerrno;
}
/** @brief Constructor
@param comp A valid VComponent with a VFREEBUSY section
*/
ICalSpanList::ICalSpanList(VComponent &comp) throw(icalerrorenum)
{
data = icalspanlist_from_vfreebusy((icalcomponent*) comp);
if (!data) throw icalerrno;
}
/** Destructor */
ICalSpanList::~ICalSpanList() {
if (data)
icalspanlist_free(data);
}
/**
* @brief Returns a VFREEBUSY component for the object.
*
* @see icalspanlist_as_vfreebusy()
*/
VComponent*
ICalSpanList::get_vfreebusy(const char *organizer, const char *attendee) throw(icalerrorenum)
{
icalcomponent *comp;
VComponent *vcomp;
comp = icalspanlist_as_vfreebusy(data, organizer, attendee);
if (comp == 0) throw icalerrno;
vcomp = new VComponent(comp);
if (vcomp == 0) throw icalerrno;
return vcomp;
}
/**
* @brief Returns a summary of events over delta_t
*
* @param delta_t Number of seconds to divide the spanlist time period
* into.
*
* This method calculates the total number of events in each time slot
* of delta_t seconds.
*
* @see icalspanlist_as_freebusy_matrix()
*/
std::vector<int> ICalSpanList::as_vector(int delta_t) throw(icalerrorenum)
{
int *matrix;
int i = 0;
std::vector<int> event_vec;
matrix = icalspanlist_as_freebusy_matrix(data, delta_t);
if (!matrix) throw ICAL_USAGE_ERROR;
while (matrix[i] != -1) {
event_vec.push_back(matrix[i]); // Add item at end of vector
}
return(event_vec);
}
|