~ubuntu-branches/ubuntu/wily/afnix/wily

« back to all changes in this revision

Viewing changes to src/srv/csm/shl/Appointer.hpp

  • Committer: Package Import Robot
  • Author(s): Nobuhiro Iwamatsu
  • Date: 2015-07-11 02:00:35 UTC
  • mfrom: (10.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20150711020035-2nhpztq7s15qyc0v
Tags: 2.5.1-1
* New upstream release. (Closes: #789968)
* Update debian/control.
  - Update Standards-Version to 3.9.6.
* Add support mips64(el) and ppc64el. (Closes: #741508, #748146)
* Add patches/support-gcc-5.x.patch. (Closes: #777767)
  - Fix build with gcc-5.x.
* Add patches/Disable-NET0001.als.patch.
  - Disable test of NET0001.als.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// ---------------------------------------------------------------------------
 
2
// - Appointer.hpp                                                           -
 
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.                  -
 
7
// -                                                                         -
 
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
// ---------------------------------------------------------------------------
 
16
 
 
17
#ifndef  AFNIX_APPOINTER_HPP
 
18
#define  AFNIX_APPOINTER_HPP
 
19
 
 
20
#ifndef  AFNIX_SET_HPP
 
21
#include "Set.hpp"
 
22
#endif
 
23
 
 
24
#ifndef  AFNIX_DATE_HPP
 
25
#include "Date.hpp"
 
26
#endif
 
27
 
 
28
#ifndef  AFNIX_SLOT_HPP
 
29
#include "Slot.hpp"
 
30
#endif
 
31
 
 
32
namespace afnix {
 
33
 
 
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
 
42
 
 
43
  class Appointer : public virtual Object {
 
44
  private:
 
45
    /// the initial time
 
46
    t_long d_time;
 
47
    /// the daily slot number
 
48
    long d_dsnm;
 
49
    /// the number of slots
 
50
    long d_snum;
 
51
    /// the pushback set
 
52
    Set  d_pset;
 
53
    /// the rule structure
 
54
    struct s_rule* p_rule;
 
55
 
 
56
  public:
 
57
    /// create a default appointer
 
58
    Appointer (void);
 
59
 
 
60
    /// create an appointer by time
 
61
    /// @param time the initial time
 
62
    Appointer (const t_long time);
 
63
    
 
64
    /// copy construct this appointer
 
65
    /// @param that the appointer to copy
 
66
    Appointer (const Appointer& that);
 
67
 
 
68
    /// destroy this appointer
 
69
    ~Appointer (void);
 
70
 
 
71
    /// @return the class name
 
72
    String repr (void) const;
 
73
 
 
74
    /// @return a clone of this object
 
75
    Object* clone (void) const;
 
76
 
 
77
    /// reset this appointer
 
78
    void reset (void);
 
79
 
 
80
    /// set the appointer time
 
81
    /// @param time the time to set
 
82
    virtual void settime (const t_long time);
 
83
 
 
84
    /// @return the appointer time
 
85
    virtual t_long gettime (void) const;
 
86
 
 
87
    /// @return the appointer minimum time
 
88
    virtual t_long getamtm (void) const;
 
89
 
 
90
    /// @return the appointer minimum time by time
 
91
    virtual t_long getamtm (const t_long mrtm) const;
 
92
 
 
93
    /// set the initial time by date
 
94
    /// @param date the date time to set
 
95
    virtual void setdate (const Date& date);
 
96
 
 
97
    /// @return the appointer date
 
98
    virtual Date getdate (void) const;
 
99
 
 
100
    /// @return the number of slots
 
101
    virtual long getsnum (void) const;
 
102
 
 
103
    /// set a block day rule
 
104
    /// @param wday the week day index to block
 
105
    virtual void setbday (const long wday);
 
106
 
 
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);
 
111
 
 
112
    /// set a max slt rule
 
113
    /// @param maxs the maximum number of slots
 
114
    virtual void setmaxs (const long maxs);
 
115
 
 
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);
 
120
 
 
121
    /// get the next available slot by duration
 
122
    /// @param dlen the slot duration
 
123
    virtual Slot getslot (const t_long dlen);
 
124
 
 
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);
 
128
 
 
129
    /// pushback a slot in the slot pool
 
130
    /// @param slot the slot to pushback
 
131
    virtual void pushback (const Slot& slot);
 
132
 
 
133
  private:
 
134
    // make the assignment operator private
 
135
    Appointer& operator = (const Appointer&);
 
136
 
 
137
  public:
 
138
    /// create a object in a generic way
 
139
    /// @param argv the argument vector
 
140
    static Object* mknew (Vector* argv);
 
141
 
 
142
    /// @return true if the given quark is defined
 
143
    bool isquark (const long quark, const bool hflg) const;
 
144
 
 
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,
 
151
                   Vector* argv);
 
152
  };
 
153
}
 
154
 
 
155
#endif