OpenWalnut  1.4.0
WSubject.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WSUBJECT_H
26 #define WSUBJECT_H
27 
28 #include <string>
29 #include <vector>
30 #ifndef Q_MOC_RUN
31 #include <boost/shared_ptr.hpp>
32 #endif
33 
34 #include "../common/WConditionSet.h"
35 #include "../common/WSharedObject.h"
36 #include "../common/WSharedSequenceContainer.h"
37 
38 #include "WPersonalInformation.h"
39 
40 
41 class WDataSet;
42 
43 /**
44  * Container for all WDataSets belonging to one subject or patient.
45  * \ingroup dataHandler
46  */
47 class WSubject // NOLINT
48 {
49  /**
50  * Only tests are allowed as friends.
51  */
52  friend class WSubjectTest;
53 
54 public:
55  /**
56  * List of some standard subjects. This is currently used for the default subject as we do not have any others.
57  */
58  enum
59  {
60  SUBJECT_UNKNOWN = 0
61  };
62 
63  /**
64  * For shortening: a type defining a shared vector of WSubject pointers.
65  */
66  typedef std::vector< boost::shared_ptr< WDataSet > > DatasetContainerType;
67 
68  /**
69  * The alias for a shared container.
70  */
72 
73  /**
74  * The dataset iterator.
75  */
76  typedef DatasetContainerType::iterator DatasetIterator;
77 
78  /**
79  * The dataset const iterator.
80  */
81  typedef DatasetContainerType::const_iterator DatasetConstIterator;
82 
83  /**
84  * Constructs a dummy subject.
85  */
86  WSubject();
87 
88  /**
89  * Allows one to give the subject information the person during construction.
90  *
91  * \param personInfo personal information object
92  */
93  explicit WSubject( WPersonalInformation personInfo );
94 
95  /**
96  * Destructs the subject. Removes all datasets from the list.
97  */
98  virtual ~WSubject();
99 
100  /**
101  * Returns the name of the subject. See WPersonalInformation for details on the name.
102  *
103  * \return the name of the subject extracted from this subject's WPersonalInformation.
104  */
105  std::string getName() const;
106 
107  /**
108  * Gives the personal information of a subject.
109  *
110  * \return the personal information of the subject.
111  */
113 
114  /**
115  * Insert a new dataset referenced by a pointer.
116  *
117  * \param dataset a pointer to the dataset that will be added
118  */
119  void addDataSet( boost::shared_ptr< WDataSet > dataset );
120 
121  /**
122  * Removes the specified dataset if it is in the set.
123  *
124  * \param dataset the dataset to remove.
125  */
126  void removeDataSet( boost::shared_ptr< WDataSet > dataset );
127 
128  /**
129  * Remove all datasets from the subjects.
130  */
131  void clear();
132 
133  /**
134  * Returns read-access to the dataset list. As long as the returned ticket exists, the list of datasets can't be changed by others.
135  *
136  * \return the read ticket.
137  */
139 
140  /**
141  * Returns write-access to the dataset list. As long as the returned ticket exists, the list of datasets can't be changed by others.
142  *
143  * \return the write ticket.
144  */
146 
147  /**
148  * This condition fires whenever the list of datasets changes, or one dataset got marked as "dirty" (threshold, opacity, ...).
149  *
150  * \return the condition
151  */
152  boost::shared_ptr< WCondition > getChangeCondition() const;
153 
154  /**
155  * This condition fires whenever the list of datasets changes.
156  *
157  * \return the condition
158  */
159  boost::shared_ptr< WCondition > getListChangeCondition() const;
160 
161 protected:
162  /**
163  * A container for all WDataSet.
164  */
165  DatasetSharedContainerType m_datasets;
166 
167  /**
168  * This condition set fires whenever one dataset gets dirty or the list of datasets changes.
169  */
170  boost::shared_ptr< WConditionSet > m_changeCondition;
171 
172  /**
173  * This condition set fires whenever the list of datasets changes.
174  */
175  boost::shared_ptr< WConditionSet > m_listChangeCondition;
176 
177 private:
178  WPersonalInformation m_personalInfo; //!< Information on the person represented by this WSubject.
179 };
180 
181 #endif // WSUBJECT_H
182 
DatasetSharedContainerType::WriteTicket getDatasetsForWriting() const
Returns write-access to the dataset list.
Definition: WSubject.cpp:106
boost::shared_ptr< WSharedObjectTicketWrite< DatasetContainerType > > WriteTicket
Type for write tickets.
Definition: WSharedObject.h:69
WPersonalInformation getPersonalInformation() const
Gives the personal information of a subject.
Definition: WSubject.cpp:62
WPersonalInformation m_personalInfo
Information on the person represented by this WSubject.
Definition: WSubject.h:178
DatasetSharedContainerType m_datasets
A container for all WDataSet.
Definition: WSubject.h:165
The tests for our subject class.
Definition: WSubject_test.h:37
Base class for all data set types.
Definition: WDataSet.h:55
std::string getName() const
Returns the name of the subject.
Definition: WSubject.cpp:57
boost::shared_ptr< WCondition > getChangeCondition() const
This condition fires whenever the list of datasets changes, or one dataset got marked as "dirty" (thr...
Definition: WSubject.cpp:111
Container for all WDataSets belonging to one subject or patient.
Definition: WSubject.h:47
DatasetContainerType::iterator DatasetIterator
The dataset iterator.
Definition: WSubject.h:76
virtual ~WSubject()
Destructs the subject.
Definition: WSubject.cpp:52
void addDataSet(boost::shared_ptr< WDataSet > dataset)
Insert a new dataset referenced by a pointer.
Definition: WSubject.cpp:67
DatasetContainerType::const_iterator DatasetConstIterator
The dataset const iterator.
Definition: WSubject.h:81
DatasetSharedContainerType::ReadTicket getDatasets() const
Returns read-access to the dataset list.
Definition: WSubject.cpp:101
boost::shared_ptr< WConditionSet > m_listChangeCondition
This condition set fires whenever the list of datasets changes.
Definition: WSubject.h:175
WSharedSequenceContainer< DatasetContainerType > DatasetSharedContainerType
The alias for a shared container.
Definition: WSubject.h:71
WSubject()
Constructs a dummy subject.
Definition: WSubject.cpp:36
std::vector< boost::shared_ptr< WDataSet > > DatasetContainerType
For shortening: a type defining a shared vector of WSubject pointers.
Definition: WSubject.h:66
void removeDataSet(boost::shared_ptr< WDataSet > dataset)
Removes the specified dataset if it is in the set.
Definition: WSubject.cpp:75
boost::shared_ptr< WConditionSet > m_changeCondition
This condition set fires whenever one dataset gets dirty or the list of datasets changes.
Definition: WSubject.h:170
A structure that holds all relevant information about the subject.
boost::shared_ptr< WCondition > getListChangeCondition() const
This condition fires whenever the list of datasets changes.
Definition: WSubject.cpp:116
boost::shared_ptr< WSharedObjectTicketRead< DatasetContainerType > > ReadTicket
Type for read tickets.
Definition: WSharedObject.h:64
void clear()
Remove all datasets from the subjects.
Definition: WSubject.cpp:90