OpenWalnut  1.4.0
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 <boost/shared_ptr.hpp>
00031 
00032 #include "../common/WConditionSet.h"
00033 #include "../common/WSharedObject.h"
00034 #include "../common/WSharedSequenceContainer.h"
00035 
00036 #include "WPersonalInformation.h"
00037 
00038 
00039 class WDataSet;
00040 
00041 /**
00042  * Container for all WDataSets belonging to one subject or patient.
00043  * \ingroup dataHandler
00044  */
00045 class WSubject // NOLINT
00046 {
00047     /**
00048      * Only tests are allowed as friends.
00049      */
00050     friend class WSubjectTest;
00051 
00052 public:
00053     /**
00054      * List of some standard subjects. This is currently used for the default subject as we do not have any others.
00055      */
00056     enum
00057     {
00058         SUBJECT_UNKNOWN = 0
00059     };
00060 
00061     /**
00062      * For shortening: a type defining a shared vector of WSubject pointers.
00063      */
00064     typedef std::vector< boost::shared_ptr< WDataSet > > DatasetContainerType;
00065 
00066     /**
00067      * The alias for a shared container.
00068      */
00069     typedef WSharedSequenceContainer< DatasetContainerType > DatasetSharedContainerType;
00070 
00071     /**
00072      * The dataset iterator.
00073      */
00074     typedef DatasetContainerType::iterator DatasetIterator;
00075 
00076     /**
00077      * The dataset const iterator.
00078      */
00079     typedef DatasetContainerType::const_iterator DatasetConstIterator;
00080 
00081     /**
00082      * Constructs a dummy subject.
00083      */
00084     WSubject();
00085 
00086     /**
00087      * Allows one to give the subject information the person during construction.
00088      *
00089      * \param personInfo personal information object
00090      */
00091     explicit WSubject( WPersonalInformation personInfo );
00092 
00093     /**
00094      * Destructs the subject. Removes all datasets from the list.
00095      */
00096     virtual ~WSubject();
00097 
00098     /**
00099      * Returns the name of the subject. See WPersonalInformation for details on the name.
00100      *
00101      * \return the name of the subject extracted from this subject's WPersonalInformation.
00102      */
00103     std::string getName() const;
00104 
00105     /**
00106      * Gives the personal information of a subject.
00107      *
00108      * \return the personal information of the subject.
00109      */
00110     WPersonalInformation getPersonalInformation() const;
00111 
00112     /**
00113      * Insert a new dataset referenced by a pointer.
00114      *
00115      * \param dataset a pointer to the dataset that will be added
00116      */
00117     void addDataSet( boost::shared_ptr< WDataSet > dataset );
00118 
00119     /**
00120      * Removes the specified dataset if it is in the set.
00121      *
00122      * \param dataset the dataset to remove.
00123      */
00124     void removeDataSet( boost::shared_ptr< WDataSet > dataset );
00125 
00126     /**
00127      * Remove all datasets from the subjects.
00128      */
00129     void clear();
00130 
00131     /**
00132      * Returns read-access to the dataset list. As long as the returned ticket exists, the list of datasets can't be changed by others.
00133      *
00134      * \return the read ticket.
00135      */
00136     DatasetSharedContainerType::ReadTicket getDatasets() const;
00137 
00138     /**
00139      * Returns write-access to the dataset list. As long as the returned ticket exists, the list of datasets can't be changed by others.
00140      *
00141      * \return the write ticket.
00142      */
00143     DatasetSharedContainerType::WriteTicket getDatasetsForWriting() const;
00144 
00145     /**
00146      * This condition fires whenever the list of datasets changes, or one dataset got marked as "dirty" (threshold, opacity, ...).
00147      *
00148      * \return the condition
00149      */
00150     boost::shared_ptr< WCondition > getChangeCondition() const;
00151 
00152     /**
00153      * This condition fires whenever the list of datasets changes.
00154      *
00155      * \return the condition
00156      */
00157     boost::shared_ptr< WCondition > getListChangeCondition() const;
00158 
00159 protected:
00160     /**
00161      * A container for all WDataSet.
00162      */
00163     DatasetSharedContainerType m_datasets;
00164 
00165     /**
00166      * This condition set fires whenever one dataset gets dirty or the list of datasets changes.
00167      */
00168     boost::shared_ptr< WConditionSet > m_changeCondition;
00169 
00170     /**
00171      * This condition set fires whenever the list of datasets changes.
00172      */
00173     boost::shared_ptr< WConditionSet > m_listChangeCondition;
00174 
00175 private:
00176     WPersonalInformation m_personalInfo; //!< Information on the person represented by this WSubject.
00177 };
00178 
00179 #endif  // WSUBJECT_H
00180