Debian Codegraph @

src/plugins/schedulers/tj/taskjuggler/Shift.h

raw
1 /*
2 * Shift.h - TaskJuggler
3 *
4 * Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006
5 * by Chris Schlaeger <[email protected]>
6 * SPDX-FileCopyrightText: 2016 Dag Andersen <[email protected]>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of version 2 of the GNU General Public License as
10 * published by the Free Software Foundation.
11 *
12 * $Id$
13 */
14 #ifndef _Shift_h_
15 #define _Shift_h_
16
17 #include <time.h>
18
19 #include <QList>
20
21 #include "CoreAttributes.h"
22
23 namespace TJ
24 {
25
26 class Interval;
27 class ShiftListIterator;
28
29 /**
30 * @short Stores all shift related information.
31 * @author Chris Schlaeger <[email protected]>
32 */
33 class Shift : public CoreAttributes
34 {
35 public:
36 Shift(Project* prj, const QString& i, const QString& n, Shift* p,
37 const QString& df = QString(), uint dl = 0);
38 ~Shift() override;
39
40 CAType getType() const override { return CA_Shift; }
41
42 Shift* getParent() const { return static_cast<Shift*>(parent); }
43
44 ShiftListIterator getSubListIterator() const;
45
46 void inheritValues();
47
48 void setWorkingHours(int day, const QList<Interval*>& l);
49
50 QList<Interval*>* getWorkingHours(int day) const
51 {
52 return workingHours[day];
53 }
54 const QList<Interval*>* const * getWorkingHours() const
55 {
56 return static_cast<const QList<Interval*>* const*>(workingHours);
57 }
58
59 bool isOnShift(const Interval& iv) const;
60
61 bool isVacationDay(time_t day) const;
62
63 /// Add non-overlapping work intervals
64 /// This will override usage of workingHours[]
65 void addWorkingInterval(const Interval &interval);
66 QList<Interval> getWorkingIntervals() const;
67
68 private:
69 QList<Interval*>* workingHours[7];
70 QList<Interval> workingIntervals;
71 };
72
73 } // namespace TJ
74
75 PLANTJ_EXPORT QDebug operator<<(QDebug dbg, const TJ::Shift &s);
76 PLANTJ_EXPORT QDebug operator<<(QDebug dbg, const TJ::Shift *s);
77
78 #endif