00001 #ifndef TASK_H
00002 #define TASK_H
00003
00004 #include "storabledata.h"
00005 #include "taskstates.h"
00006 #include "invitation.h"
00007 #include "reservation.h"
00008
00009 #include <tools/global.h>
00010
00011 class QString;
00012 class QDateTime;
00013
00014 template<typename T>
00015 class QList;
00016
00017 template<typename Key, typename Value>
00018 class QMap;
00019
00020 namespace domain
00021 {
00022
00023 class ResourceType;
00024 class UserType;
00025 class Reservation;
00026 class StateChangeData;
00027 class Schedule;
00028 class Resource;
00029 class Project;
00030 class User;
00031 class Invitation;
00032 class TaskType;
00033 struct TaskPrivate;
00034
00057 class DOMAIN_EXPORT Task : public StorableData
00058 {
00059 Q_OBJECT
00060
00061 friend class TaskManagerData;
00062 friend class TaskState;
00063 friend class Invitation;
00064 friend class Reservation;
00065 friend class TaskPrivate;
00066
00067 public:
00068
00082 void setField(const QString& id, const QVariant& value);
00083
00090 QVariant field(const QString& id) const;
00091
00095 QMap<QString, QVariant> fields() const;
00096
00102 QList<const Reservation*> reservations() const;
00103
00110 unsigned nbActiveReservations(ResourceType* type) const;
00111
00115 QList<const Invitation*> invitations() const;
00116
00123 unsigned nbAcceptedInvitations(UserType* type) const;
00124
00128 const Schedule& schedule() const;
00129
00133 QString stateString() const;
00134
00138 TaskState::SettableState state() const;
00139
00143 const Project* project() const;
00144
00148 const User* user() const;
00149
00154 QDateTime earliestEndTime() const;
00155
00159 QList<const Task*> subTasks() const;
00160
00164 QList<const Task*> superTasks() const;
00165
00169 QList<const Task*> allSuperTasks() const;
00170
00181 void setState(TaskState::SettableState state);
00182
00190 StateChangeData canHaveAsState(TaskState::SettableState state) const;
00191
00199 void setProject(Project* project);
00200
00210 void addSubTask(Task* dependency);
00211
00217 void removeSubTask(Task* dependency);
00218
00229 bool dependsOn(const Task* other) const;
00230
00234 bool isAvailable() const;
00235
00241 bool requirementsAreFulfilled() const;
00242
00248 bool canBeSuccessful() const;
00249
00255 TaskType* taskType() const;
00256
00257 void notify();
00258
00259 private:
00260
00275 Task(TaskType* type, User* user, const Schedule& schedule,
00276 TaskState::SettableState state = TaskState::Unfinished,
00277 const QList<Task*>& subTasks = QList<Task*>(),
00278 const QList<InvitationData>& invitations = QList<InvitationData>(),
00279 const QList<ReservationData>& reservations = QList<ReservationData>());
00280
00286 virtual ~Task();
00287
00288 Task(const Task& other);
00289 Task& operator=(const Task& other);
00290
00294 void setState(TaskState* state);
00295
00296
00297
00298 void _setField(const QString& id, const QVariant& value);
00299 void _addReservation(Reservation* reservation);
00300 void _setProject(Project* project);
00301 void _addSubTask(Task* dependency);
00302
00303 QList<Task*> superTasks();
00304
00319 void addInvitation(Invitation* invitation);
00320
00324 void removeInvitation(Invitation* invitation);
00325
00341 void addReservation(Reservation* reservation);
00342
00346 void removeReservation(Reservation* reservation);
00347
00351 QList<StorableData*> dependentData() const;
00352
00353 TaskPrivate* const d;
00354 };
00355
00356 }
00357
00358
00359 #endif