domain::TaskManagerData Class Reference

Class to store all data in the domain layer. More...

#include <taskmanagerdata.h>

Inheritance diagram for domain::TaskManagerData:
Inheritance graph
[legend]
Collaboration diagram for domain::TaskManagerData:
Collaboration graph
[legend]

List of all members.

Signals

void timeChanged (const QDateTime &newTime)
void dataChanged ()
void tasksChanged ()
void usersChanged ()
void resourcesChanged ()
void reservationsChanged ()
void projectsChanged ()
void invitationsChanged ()

Public Member Functions

Clockclock () const
QList< Task * > tasks () const
QList< Task * > tasksForUser (const User *user) const
QList< Reservation * > reservations () const
QList< User * > users () const
QList< User * > allUsers () const
UseradminUser () const
QList< Invitation * > invitations () const
QList< Resource * > resources () const
QList< Project * > projects () const
Tasktask (const Task *task) const
Resourceresource (const Resource *resource)
Projectproject (const Project *project)
Useruser (const User *user)
Invitationinvitation (const Invitation *invitation)
 Returns a non-const pointer to the given invitation.
TaskcreateTask (TaskType *type, const User *user, const Schedule &schedule, TaskState::SettableState state=TaskState::Unfinished, const QList< Task * > &subTasks=QList< Task * >(), const QList< InvitationData > &invitations=QList< InvitationData >(), const QList< ReservationData > &reservations=QList< ReservationData >())
ReservationcreateReservation (const Task *task, const Resource *resource, const QDateTime &time, const Duration &duration)
UsercreateUser (UserType *type, const QString &name)
InvitationcreateInvitation (const Task *task, const User *user)
ResourcecreateResource (const QString &description, ResourceType *type)
ProjectcreateProject (const QString &description)
void removeData (const StorableData *data)
void clear ()
void clearTheme ()
TaskTypecreateTaskType (QString id, QString name)
UserTypecreateUserType (QString id, QString name)
ResourceTypecreateResourceType (QString id, QString name)
QList< UserType * > userTypes () const
QList< TaskType * > taskTypes () const
QList< ResourceType * > resourceTypes () const
TypetypeById (const QString &id) const
bool hasData () const
bool hasTheme () const

Static Public Member Functions

static TaskManagerDatainstance ()

Private Member Functions

friend Task::Task (TaskType *type, User *, const Schedule &, TaskState::SettableState, const QList< Task * > &, const QList< InvitationData > &, const QList< ReservationData > &)
 TaskManagerData ()
 ~TaskManagerData ()
 TaskManagerData (const TaskManagerData &other)
TaskManagerDataoperator= (const TaskManagerData &other)
Invitation_createInvitation (Task *task, User *user)
Reservation_createReservation (Task *task, Resource *resource, const QDateTime &time, const Duration &duration)
void addType (Type *type)

Private Attributes

TaskManagerDataPrivate *const d

Detailed Description

Class to store all data in the domain layer.

This class is used to create, store and remove data from the domain layer. The getters all return non-const pointers so they can be used to modify the data. It is, however, not possible to delete the data with the returned pointers since the destructors of all data classes are private.

Memory Management

All data that is part of the domain layer can only be created through an object of this class. All created data can only be removed by the same object but it is not necessary to remove all created data before removing this object. The destructor takes care of this.

There can only be one object of this class at any time. This is ensured by implementing the singleton pattern for this class. This singleton object is accessed through instance().

Const- vs. non-const pointers

The design of the API of this class follows two simple rules:

The owner of this object (ie the control layer) should have the means to modify data, it can use the getters to access modifyable data.

It is, however, not a good idea to share those non-const pointers with other layers, to prevent them from modifying data. This means that all communication between the control layer and other parts of the program should be done with const pointers. Therefore, to make life easier for a controller, all methods in this class accept const-pointers. If the given const pointer is part of this object's data, it will be converted to a non-const pointer for internal use. There are also convenience methods that convert any const pointer to a non-const one. This will, of course, only work if the given pointer is part of this object.

Definition at line 73 of file taskmanagerdata.h.


Constructor & Destructor Documentation

domain::TaskManagerData::TaskManagerData (  )  [private]

Constructs an empty data collection.

Definition at line 73 of file taskmanagerdata.cpp.

Here is the call graph for this function:

domain::TaskManagerData::~TaskManagerData (  )  [private]

Destroys all data that has been created by this object.

Definition at line 88 of file taskmanagerdata.cpp.

Here is the call graph for this function:


Member Function Documentation

Invitation * domain::TaskManagerData::_createInvitation ( Task task,
User user 
) [private]

This method does the same as createInvitation() except that it does not require the parameters to already be stored in this object. This is used in Task s constructor so it can create invitations without being fully created itself.

Definition at line 306 of file taskmanagerdata.cpp.

Here is the call graph for this function:

Reservation * domain::TaskManagerData::_createReservation ( Task task,
Resource resource,
const QDateTime &  time,
const Duration duration 
) [private]

This method does the same as createReservation() except that it does not require the parameters to already be stored in this object. This is used in Task s constructor so it can create reservations without being fully created itself.

Definition at line 344 of file taskmanagerdata.cpp.

Here is the call graph for this function:

void domain::TaskManagerData::addType ( Type type  )  [private]

Adds the given type to this objects list of types. This is used by all the createType() methods.

Exceptions:
InvalidDataException If there already exists a type with the new types id.

Definition at line 148 of file taskmanagerdata.cpp.

Here is the call graph for this function:

User * domain::TaskManagerData::adminUser (  )  const

Returns the administrator user.

Definition at line 220 of file taskmanagerdata.cpp.

QList< User * > domain::TaskManagerData::allUsers (  )  const

Returns a list of all User objects created with createUser() as well as the administrator user.

See also:
users()

Definition at line 215 of file taskmanagerdata.cpp.

Here is the call graph for this function:

void domain::TaskManagerData::clear (  ) 

Removes all the data from this object.

See also:
removeData().

Definition at line 102 of file taskmanagerdata.cpp.

Here is the call graph for this function:

void domain::TaskManagerData::clearTheme (  ) 

Removes all Type objects from this object. This also calls clear().

Definition at line 136 of file taskmanagerdata.cpp.

Here is the call graph for this function:

Clock * domain::TaskManagerData::clock (  )  const

Returns the clock used by this object.

Definition at line 182 of file taskmanagerdata.cpp.

Invitation * domain::TaskManagerData::createInvitation ( const Task task,
const User user 
)

Creates a new Invitation object.

The newly created invitation will be stored in this object.

See also:
Invitation::Invitation().

Definition at line 295 of file taskmanagerdata.cpp.

Here is the call graph for this function:

Project * domain::TaskManagerData::createProject ( const QString &  description  ) 

Creates and returns a new Project object.

The newly created project will be stored in this object.

See also:
Project::Project().

Definition at line 286 of file taskmanagerdata.cpp.

Here is the call graph for this function:

Reservation * domain::TaskManagerData::createReservation ( const Task task,
const Resource resource,
const QDateTime &  time,
const Duration duration 
)

Creates and returns a new Reservation object.

The newly created reservation will be stored in this object.

See also:
Reservation::Reservation().

Definition at line 328 of file taskmanagerdata.cpp.

Here is the call graph for this function:

Resource * domain::TaskManagerData::createResource ( const QString &  description,
ResourceType type 
)

Creates and returns a new Resource object.

The newly created resource will be stored in this object.

See also:
Resource::Resource().

Definition at line 315 of file taskmanagerdata.cpp.

Here is the call graph for this function:

ResourceType * domain::TaskManagerData::createResourceType ( QString  id,
QString  name 
)

Creates and returns a new ResourceType object.

See also:
ResourceType::ResourceType(), addType().

Definition at line 175 of file taskmanagerdata.cpp.

Here is the call graph for this function:

Task * domain::TaskManagerData::createTask ( TaskType type,
const User user,
const Schedule schedule,
TaskState::SettableState  state = TaskState::Unfinished,
const QList< Task * > &  subTasks = QList<Task*>(),
const QList< InvitationData > &  invitations = QList<InvitationData>(),
const QList< ReservationData > &  reservations = QList<ReservationData>() 
)

Creates and returns a new Task object.

The newly created task will be stored in this object.

See also:
Task::Task().

Definition at line 268 of file taskmanagerdata.cpp.

Here is the call graph for this function:

TaskType * domain::TaskManagerData::createTaskType ( QString  id,
QString  name 
)

Creates and returns a new TaskType object.

See also:
TaskType::TaskType(), addType().

Definition at line 161 of file taskmanagerdata.cpp.

Here is the call graph for this function:

User * domain::TaskManagerData::createUser ( UserType type,
const QString &  name 
)

Creates and returns a new User object.

The newly created user will be stored in this object.

See also:
User::User().

Definition at line 358 of file taskmanagerdata.cpp.

Here is the call graph for this function:

UserType * domain::TaskManagerData::createUserType ( QString  id,
QString  name 
)

Creates and returns a new UserType object.

See also:
UserType::UserType(), addType().

Definition at line 168 of file taskmanagerdata.cpp.

Here is the call graph for this function:

void domain::TaskManagerData::dataChanged (  )  [signal]

Emitted when some data changed.

A data change can be either

  • Data added
  • Data removed
  • Changing some property of a data class
See also:
StorableData::dataChanged()
bool domain::TaskManagerData::hasData (  )  const

Indicates whether any data is stored in this object.

Note:
The (always existing) admin user does not count as data.

Definition at line 432 of file taskmanagerdata.cpp.

bool domain::TaskManagerData::hasTheme (  )  const

Indicates whether any types are stored in this object.

Definition at line 437 of file taskmanagerdata.cpp.

TaskManagerData * domain::TaskManagerData::instance (  )  [static]

Returns the singleton object of this class.

Definition at line 96 of file taskmanagerdata.cpp.

Invitation * domain::TaskManagerData::invitation ( const Invitation invitation  ) 

Returns a non-const pointer to the given invitation.

Returns:
A non-const pointer to the given invitation if it was created by this object.
0 otherwise.
See also:
Const- vs. non-const pointers

Definition at line 263 of file taskmanagerdata.cpp.

QList< Invitation * > domain::TaskManagerData::invitations (  )  const

Returns a list of all Invitation object.

Definition at line 225 of file taskmanagerdata.cpp.

void domain::TaskManagerData::invitationsChanged (  )  [signal]

Emitted when some invitation changed.

See also:
dataChanged()
Project * domain::TaskManagerData::project ( const Project project  ) 

Returns a non-const pointer to the given project.

Returns:
A non-const pointer to the given project if it was created by this object.
0 otherwise.
See also:
Const- vs. non-const pointers

Definition at line 250 of file taskmanagerdata.cpp.

QList< Project * > domain::TaskManagerData::projects (  )  const

Returns a list of all Project objects created with createProject().

Definition at line 235 of file taskmanagerdata.cpp.

void domain::TaskManagerData::projectsChanged (  )  [signal]

Emitted when some project changed.

See also:
dataChanged()
void domain::TaskManagerData::removeData ( const StorableData data  ) 

Removes and deletes the given data.

This method is the only way to remove data that has been created with this object.

If the given data has any dependent data, that will also be removed.

See also:
StorableData, StorableData::dependentData(), Memory Management.

Definition at line 376 of file taskmanagerdata.cpp.

Here is the call graph for this function:

QList< Reservation * > domain::TaskManagerData::reservations (  )  const

Returns a list of all Reservation objects created with createReservation().

Definition at line 205 of file taskmanagerdata.cpp.

void domain::TaskManagerData::reservationsChanged (  )  [signal]

Emitted when some reservation changed.

See also:
dataChanged()
Resource * domain::TaskManagerData::resource ( const Resource resource  ) 

Returns a non-const pointer to the given resource.

Returns:
A non-const pointer to the given resource if it was created by this object.
0 otherwise.
See also:
Const- vs. non-const pointers

Definition at line 245 of file taskmanagerdata.cpp.

QList< Resource * > domain::TaskManagerData::resources (  )  const

Returns a list of all Resource objects created with createResource().

Definition at line 230 of file taskmanagerdata.cpp.

void domain::TaskManagerData::resourcesChanged (  )  [signal]

Emitted when some resource changed.

See also:
dataChanged()
QList< ResourceType * > domain::TaskManagerData::resourceTypes (  )  const

Returns a list of ResourceType objects created with createResourceType().

Definition at line 409 of file taskmanagerdata.cpp.

Task * domain::TaskManagerData::task ( const Task task  )  const

Returns a non-const pointer to the given task.

Returns:
A non-const pointer to the given task if it was created by this object.
0 otherwise.
See also:
Const- vs. non-const pointers

Definition at line 240 of file taskmanagerdata.cpp.

QList< Task * > domain::TaskManagerData::tasks (  )  const

Returns a list of all Task objects created createTask().

Definition at line 187 of file taskmanagerdata.cpp.

void domain::TaskManagerData::tasksChanged (  )  [signal]

Emitted when some task changed.

See also:
dataChanged()
QList< Task * > domain::TaskManagerData::tasksForUser ( const User user  )  const

Returns a list of all Task objects owned by the given user.

Definition at line 192 of file taskmanagerdata.cpp.

Here is the call graph for this function:

QList< TaskType * > domain::TaskManagerData::taskTypes (  )  const

Returns a list of TaskType objects created with createTaskType().

Definition at line 414 of file taskmanagerdata.cpp.

void domain::TaskManagerData::timeChanged ( const QDateTime &  newTime  )  [signal]

Emitted when the system time changed.

Parameters:
newTime The new time
Type * domain::TaskManagerData::typeById ( const QString &  id  )  const

Returns the Type object with the given id or 0 if there is no such object.

Definition at line 424 of file taskmanagerdata.cpp.

User * domain::TaskManagerData::user ( const User user  ) 

Returns a non-const pointer to the given user.

Returns:
A non-const pointer to the given user if it was created by this object.
0 otherwise.
See also:
Const- vs. non-const pointers

Definition at line 255 of file taskmanagerdata.cpp.

QList< User * > domain::TaskManagerData::users (  )  const

Returns a list of all User objects created with createUser().

Definition at line 210 of file taskmanagerdata.cpp.

void domain::TaskManagerData::usersChanged (  )  [signal]

Emitted when some user changed.

See also:
dataChanged()
QList< UserType * > domain::TaskManagerData::userTypes (  )  const

Returns a list of UserType objects created with createUserType().

Definition at line 419 of file taskmanagerdata.cpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Enumerations Enumerator
Generated on Thu May 27 14:20:17 2010 for MopTaskManager by  doxygen 1.6.3