OpenWalnut  1.5.0dev
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 <memory>
29 #include <string>
30 #include <vector>
31 
32 
33 #include "../common/WConditionSet.h"
34 #include "../common/WSharedObject.h"
35 #include "../common/WSharedSequenceContainer.h"
36 #include "WPersonalInformation.h"
37 
38 
39 class WDataSet;
40 
41 /**
42  * Container for all WDataSets belonging to one subject or patient.
43  * \ingroup dataHandler
44  */
45 class WSubject // NOLINT
46 {
47  /**
48  * Only tests are allowed as friends.
49  */
50  friend class WSubjectTest;
51 
52 public:
53  /**
54  * List of some standard subjects. This is currently used for the default subject as we do not have any others.
55  */
56  enum
57  {
58  SUBJECT_UNKNOWN = 0
59  };
60 
61  /**
62  * For shortening: a type defining a shared vector of WSubject pointers.
63  */
64  typedef std::vector< std::shared_ptr< WDataSet > > DatasetContainerType;
65 
66  /**
67  * The alias for a shared container.
68  */
70 
71  /**
72  * The dataset iterator.
73  */
74  typedef DatasetContainerType::iterator DatasetIterator;
75 
76  /**
77  * The dataset const iterator.
78  */
79  typedef DatasetContainerType::const_iterator DatasetConstIterator;
80 
81  /**
82  * Constructs a dummy subject.
83  */
84  WSubject();
85 
86  /**
87  * Allows one to give the subject information the person during construction.
88  *
89  * \param personInfo personal information object
90  */
91  explicit WSubject( WPersonalInformation personInfo );
92 
93  /**
94  * Destructs the subject. Removes all datasets from the list.
95  */
96  virtual ~WSubject();
97 
98  /**
99  * Returns the name of the subject. See WPersonalInformation for details on the name.
100  *
101  * \return the name of the subject extracted from this subject's WPersonalInformation.
102  */
103  std::string getName() const;
104 
105  /**
106  * Gives the personal information of a subject.
107  *
108  * \return the personal information of the subject.
109  */
111 
112  /**
113  * Insert a new dataset referenced by a pointer.
114  *
115  * \param dataset a pointer to the dataset that will be added
116  */
117  void addDataSet( std::shared_ptr< WDataSet > dataset );
118 
119  /**
120  * Removes the specified dataset if it is in the set.
121  *
122  * \param dataset the dataset to remove.
123  */
124  void removeDataSet( std::shared_ptr< WDataSet > dataset );
125 
126  /**
127  * Remove all datasets from the subjects.
128  */
129  void clear();
130 
131  /**
132  * Returns read-access to the dataset list. As long as the returned ticket exists, the list of datasets can't be changed by others.
133  *
134  * \return the read ticket.
135  */
137 
138  /**
139  * Returns write-access to the dataset list. As long as the returned ticket exists, the list of datasets can't be changed by others.
140  *
141  * \return the write ticket.
142  */
144 
145  /**
146  * This condition fires whenever the list of datasets changes, or one dataset got marked as "dirty" (threshold, opacity, ...).
147  *
148  * \return the condition
149  */
150  std::shared_ptr< WCondition > getChangeCondition() const;
151 
152  /**
153  * This condition fires whenever the list of datasets changes.
154  *
155  * \return the condition
156  */
157  std::shared_ptr< WCondition > getListChangeCondition() const;
158 
159 protected:
160  /**
161  * A container for all WDataSet.
162  */
164 
165  /**
166  * This condition set fires whenever one dataset gets dirty or the list of datasets changes.
167  */
168  std::shared_ptr< WConditionSet > m_changeCondition;
169 
170  /**
171  * This condition set fires whenever the list of datasets changes.
172  */
173  std::shared_ptr< WConditionSet > m_listChangeCondition;
174 
175 private:
176  WPersonalInformation m_personalInfo; //!< Information on the person represented by this WSubject.
177 };
178 
179 #endif // WSUBJECT_H
180 
Base class for all data set types.
Definition: WDataSet.h:50
A structure that holds all relevant information about the subject.
std::shared_ptr< WSharedObjectTicketRead< T > > ReadTicket
Type for read tickets.
Definition: WSharedObject.h:65
std::shared_ptr< WSharedObjectTicketWrite< T > > WriteTicket
Type for write tickets.
Definition: WSharedObject.h:70
The tests for our subject class.
Definition: WSubject_test.h:40
Container for all WDataSets belonging to one subject or patient.
Definition: WSubject.h:46
DatasetContainerType::iterator DatasetIterator
The dataset iterator.
Definition: WSubject.h:74
WSharedSequenceContainer< DatasetContainerType > DatasetSharedContainerType
The alias for a shared container.
Definition: WSubject.h:69
DatasetSharedContainerType::WriteTicket getDatasetsForWriting() const
Returns write-access to the dataset list.
Definition: WSubject.cpp:104
std::shared_ptr< WConditionSet > m_listChangeCondition
This condition set fires whenever the list of datasets changes.
Definition: WSubject.h:173
void removeDataSet(std::shared_ptr< WDataSet > dataset)
Removes the specified dataset if it is in the set.
Definition: WSubject.cpp:73
std::vector< std::shared_ptr< WDataSet > > DatasetContainerType
For shortening: a type defining a shared vector of WSubject pointers.
Definition: WSubject.h:64
DatasetSharedContainerType m_datasets
A container for all WDataSet.
Definition: WSubject.h:163
DatasetContainerType::const_iterator DatasetConstIterator
The dataset const iterator.
Definition: WSubject.h:79
std::shared_ptr< WCondition > getListChangeCondition() const
This condition fires whenever the list of datasets changes.
Definition: WSubject.cpp:114
WSubject()
Constructs a dummy subject.
Definition: WSubject.cpp:34
DatasetSharedContainerType::ReadTicket getDatasets() const
Returns read-access to the dataset list.
Definition: WSubject.cpp:99
WPersonalInformation getPersonalInformation() const
Gives the personal information of a subject.
Definition: WSubject.cpp:60
WPersonalInformation m_personalInfo
Information on the person represented by this WSubject.
Definition: WSubject.h:176
std::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:109
void clear()
Remove all datasets from the subjects.
Definition: WSubject.cpp:88
virtual ~WSubject()
Destructs the subject.
Definition: WSubject.cpp:50
std::shared_ptr< WConditionSet > m_changeCondition
This condition set fires whenever one dataset gets dirty or the list of datasets changes.
Definition: WSubject.h:168
std::string getName() const
Returns the name of the subject.
Definition: WSubject.cpp:55
void addDataSet(std::shared_ptr< WDataSet > dataset)
Insert a new dataset referenced by a pointer.
Definition: WSubject.cpp:65