1
// ---------------------------------------------------------------------------
3
// - afnix:csm service - appointer class definition -
4
// ---------------------------------------------------------------------------
5
// - This program is free software; you can redistribute it and/or modify -
6
// - it provided that this copyright notice is kept intact. -
8
// - This program is distributed in the hope that it will be useful, but -
9
// - without any warranty; without even the implied warranty of -
10
// - merchantability or fitness for a particular purpose. In no event shall -
11
// - the copyright holder be liable for any direct, indirect, incidental or -
12
// - special damages arising in any way out of the use of this software. -
13
// ---------------------------------------------------------------------------
14
// - copyright (c) 1999-2015 amaury darsch -
15
// ---------------------------------------------------------------------------
17
#ifndef AFNIX_APPOINTER_HPP
18
#define AFNIX_APPOINTER_HPP
24
#ifndef AFNIX_DATE_HPP
28
#ifndef AFNIX_SLOT_HPP
34
/// The Appointer class is a class design to allocate time slot in a
35
/// calendar in order to fill an agenda. The appointer do not store the
36
/// slot but rather acts as a generator. the appointer algorith operates
37
/// with rules that permits to allocate the next available slot. The
38
/// basic rules permits to define regular blocked days and special blocked
39
/// days. Another rule permits to define an operating time period. Multiple
40
/// time periods are allowed. A maximum daly slots rule is also available.
41
/// @author amaury darsch
43
class Appointer : public virtual Object {
47
/// the daily slot number
49
/// the number of slots
53
/// the rule structure
54
struct s_rule* p_rule;
57
/// create a default appointer
60
/// create an appointer by time
61
/// @param time the initial time
62
Appointer (const t_long time);
64
/// copy construct this appointer
65
/// @param that the appointer to copy
66
Appointer (const Appointer& that);
68
/// destroy this appointer
71
/// @return the class name
72
String repr (void) const;
74
/// @return a clone of this object
75
Object* clone (void) const;
77
/// reset this appointer
80
/// set the appointer time
81
/// @param time the time to set
82
virtual void settime (const t_long time);
84
/// @return the appointer time
85
virtual t_long gettime (void) const;
87
/// @return the appointer minimum time
88
virtual t_long getamtm (void) const;
90
/// @return the appointer minimum time by time
91
virtual t_long getamtm (const t_long mrtm) const;
93
/// set the initial time by date
94
/// @param date the date time to set
95
virtual void setdate (const Date& date);
97
/// @return the appointer date
98
virtual Date getdate (void) const;
100
/// @return the number of slots
101
virtual long getsnum (void) const;
103
/// set a block day rule
104
/// @param wday the week day index to block
105
virtual void setbday (const long wday);
107
/// set a special day rule
108
/// @param ymon the special year month
109
/// @param mday the special month day
110
virtual void setsday (const long ymon, const long mday);
112
/// set a max slt rule
113
/// @param maxs the maximum number of slots
114
virtual void setmaxs (const long maxs);
116
/// set a valid block time rule
117
/// @param bbtm the block begin time
118
/// @param betm the block end time
119
virtual void setvbtm (const t_long bbtm, const t_long betm);
121
/// get the next available slot by duration
122
/// @param dlen the slot duration
123
virtual Slot getslot (const t_long dlen);
125
/// get the next available slot by duration and time
126
/// @param dlen the slot duration
127
virtual Slot getslot (const t_long time, const t_long dlen);
129
/// pushback a slot in the slot pool
130
/// @param slot the slot to pushback
131
virtual void pushback (const Slot& slot);
134
// make the assignment operator private
135
Appointer& operator = (const Appointer&);
138
/// create a object in a generic way
139
/// @param argv the argument vector
140
static Object* mknew (Vector* argv);
142
/// @return true if the given quark is defined
143
bool isquark (const long quark, const bool hflg) const;
145
/// apply this object with a set of arguments and a quark
146
/// @param robj the current runnable
147
/// @param nset the current nameset
148
/// @param quark the quark to apply these arguments
149
/// @param argv the arguments to apply
150
Object* apply (Runnable* robj, Nameset* nset, const long quark,