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