WSubject.h

00001 //---------------------------------------------------------------------------
00002 //
00003 // Project: OpenWalnut ( http://www.openwalnut.org )
00004 //
00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
00006 // For more information see http://www.openwalnut.org/copying
00007 //
00008 // This file is part of OpenWalnut.
00009 //
00010 // OpenWalnut is free software: you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as published by
00012 // the Free Software Foundation, either version 3 of the License, or
00013 // (at your option) any later version.
00014 //
00015 // OpenWalnut is distributed in the hope that it will be useful,
00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 // GNU Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public License
00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
00022 //
00023 //---------------------------------------------------------------------------
00024 
00025 #ifndef WSUBJECT_H
00026 #define WSUBJECT_H
00027 
00028 #include <string>
00029 #include <vector>
00030 #include <set>
00031 #include <boost/shared_ptr.hpp>
00032 
00033 #include "../common/WConditionSet.h"
00034 #include "../common/WSharedObject.h"
00035 #include "../common/WSharedSequenceContainer.h"
00036 
00037 #include "WPersonalInformation.h"
00038 #include "WExportDataHandler.h"
00039 
00040 class WDataSet;
00041 
00042 /**
00043  * Container for all WDataSets belonging to one subject or patient.
00044  * \ingroup dataHandler
00045  */
00046 class OWDATAHANDLER_EXPORT WSubject // NOLINT
00047 {
00048     /**
00049      * Only tests are allowed as friends.
00050      */
00051     friend class WSubjectTest;
00052 
00053 public:
00054     /**
00055      * List of some standard subjects. This is currently used for the default subject as we do not have any others.
00056      */
00057     enum
00058     {
00059         SUBJECT_UNKNOWN = 0
00060     };
00061 
00062     /**
00063      * For shortening: a type defining a shared vector of WSubject pointers.
00064      */
00065     typedef std::vector< boost::shared_ptr< WDataSet > > DatasetContainerType;
00066 
00067     /**
00068      * The alias for a shared container.
00069      */
00070     typedef WSharedSequenceContainer< DatasetContainerType > DatasetSharedContainerType;
00071 
00072     /**
00073      * The dataset iterator.
00074      */
00075     typedef DatasetContainerType::iterator DatasetIterator;
00076 
00077     /**
00078      * The dataset const iterator.
00079      */
00080     typedef DatasetContainerType::const_iterator DatasetConstIterator;
00081 
00082     /**
00083      * Constructs a dummy subject.
00084      */
00085     WSubject();
00086 
00087     /**
00088      * Allows to give the subject information the person during construction.
00089      *
00090      * \param personInfo personal information object
00091      */
00092     explicit WSubject( WPersonalInformation personInfo );
00093 
00094     /**
00095      * Destructs the subject. Removes all datasets from the list.
00096      */
00097     virtual ~WSubject();
00098 
00099     /**
00100      * Returns the name of the subject. See WPersonalInformation for details on the name.
00101      *
00102      * \return the name of the subject extracted from this subject's WPersonalInformation.
00103      */
00104     std::string getName() const;
00105 
00106     /**
00107      * Gives the personal information of a subject.
00108      *
00109      * \return the personal information of the subject.
00110      */
00111     WPersonalInformation getPersonalInformation() const;
00112 
00113     /**
00114      * Insert a new dataset referenced by a pointer.
00115      *
00116      * \param dataset a pointer to the dataset that will be added
00117      */
00118     void addDataSet( boost::shared_ptr< WDataSet > dataset );
00119 
00120     /**
00121      * Removes the specified dataset if it is in the set.
00122      *
00123      * \param dataset the dataset to remove.
00124      */
00125     void removeDataSet( boost::shared_ptr< WDataSet > dataset );
00126 
00127     /**
00128      * Remove all datasets from the subjects.
00129      */
00130     void clear();
00131 
00132     /**
00133      * Returns read-access to the dataset list. As long as the returned ticket exists, the list of datasets can't be changed by others.
00134      *
00135      * \return the read ticket.
00136      */
00137     DatasetSharedContainerType::ReadTicket getDatasets() const;
00138 
00139     /**
00140      * Returns write-access to the dataset list. As long as the returned ticket exists, the list of datasets can't be changed by others.
00141      *
00142      * \return the write ticket.
00143      */
00144     DatasetSharedContainerType::WriteTicket getDatasetsForWriting() const;
00145 
00146     /**
00147      * This condition fires whenever the list of datasets changes, or one dataset got marked as "dirty" (threshold, opacity, ...).
00148      *
00149      * \return the condition
00150      */
00151     boost::shared_ptr< WCondition > getChangeCondition() const;
00152 
00153     /**
00154      * This condition fires whenever the list of datasets changes.
00155      *
00156      * \return the condition
00157      */
00158     boost::shared_ptr< WCondition > getListChangeCondition() const;
00159 
00160 protected:
00161 
00162     /**
00163      * A container for all WDataSet.
00164      */
00165     DatasetSharedContainerType m_datasets;
00166 
00167     /**
00168      * This condition set fires whenever one dataset gets dirty or the list of datasets changes.
00169      */
00170     boost::shared_ptr< WConditionSet > m_changeCondition;
00171 
00172     /**
00173      * This condition set fires whenever the list of datasets changes.
00174      */
00175     boost::shared_ptr< WConditionSet > m_listChangeCondition;
00176 
00177 private:
00178 
00179     WPersonalInformation m_personalInfo; //!< Information on the person represented by this WSubject.
00180 };
00181 
00182 #endif  // WSUBJECT_H
00183 
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends