TissueCell.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2009
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
00026 
00027 */
00028 #ifndef TISSUECELL_HPP_
00029 #define TISSUECELL_HPP_
00030 
00031 #include <boost/serialization/access.hpp>
00032 
00033 #include "Element.hpp"
00034 #include "CellTypes.hpp"
00035 #include "CellMutationStates.hpp"
00036 #include "AbstractCellCycleModel.hpp"
00037 #include "SimulationTime.hpp"
00038 
00039 class AbstractCellCycleModel; // Circular definition (cells need to know about cycle models and vice-versa).
00040 
00041 
00049 class TissueCell
00050 {
00051 private:
00052 
00054     bool mCanDivide;
00055 
00057     friend class boost::serialization::access;
00064     template<class Archive>
00065     void serialize(Archive & archive, const unsigned int version)
00066     {
00067         // If Archive is an output archive, then '&' resolves to '<<'
00068         // If Archive is an input archive, then '&' resolves to '>>'
00069         // These first four are also dealt with by {load,save}_construct_data
00070         archive & mCanDivide;
00071         archive & mCellType;
00072         archive & mMutationState;
00073         archive & mpCellCycleModel;
00074         archive & mUndergoingApoptosis;
00075         archive & mDeathTime;
00076         archive & mStartOfApoptosisTime;
00077         archive & mIsDead;
00078         archive & mIsLogged;
00079         archive & mAncestor;
00080         archive & mCellId;
00081         archive & mMaxCellId;
00082     }
00083 
00084 protected:
00085 
00086     // NB - if you add any member variables, make sure CommonCopy includes them.
00087 
00089     CellType mCellType;
00090 
00092     CellMutationState mMutationState;
00093 
00095     AbstractCellCycleModel *mpCellCycleModel;
00096 
00098     unsigned mAncestor;
00099 
00101     unsigned mCellId;
00102 
00104     static unsigned mMaxCellId;
00105 
00107     double mDeathTime;
00108 
00110     double mStartOfApoptosisTime;
00111 
00113     bool mUndergoingApoptosis;
00114 
00119     bool mIsDead;
00120 
00122     bool mIsLogged;
00123 
00129     void CommonCopy(const TissueCell& rOtherCell);
00130 
00131 public:
00132 
00141     TissueCell(CellType cellType,
00142                CellMutationState mutationState,
00143                AbstractCellCycleModel* pCellCycleModel,
00144                bool archiving = false);
00145 
00149     ~TissueCell();
00150 
00155     TissueCell(const TissueCell& rOtherCell);
00156 
00162     TissueCell& operator=(const TissueCell& rOtherCell);
00163 
00169     void SetBirthTime(double birthTime);
00170 
00176     void SetCellCycleModel(AbstractCellCycleModel* pCellCycleModel);
00177 
00181     AbstractCellCycleModel* GetCellCycleModel() const;
00182 
00186     void InitialiseCellCycleModel();
00187 
00191     double GetAge() const;
00192 
00196     double GetBirthTime() const;
00197 
00201     double GetStartOfApoptosisTime() const;
00202 
00206     CellType GetCellType() const;
00207 
00213     void SetCellType(CellType cellType);
00214 
00218     CellMutationState GetMutationState() const;
00219 
00225     void SetMutationState(CellMutationState mutationState);
00226 
00231     bool ReadyToDivide();
00232 
00239     TissueCell Divide();
00240 
00247     void StartApoptosis(bool setDeathTime=true);
00248 
00253     void Kill();
00254 
00258     bool HasApoptosisBegun() const;
00259 
00263     double TimeUntilDeath() const;
00264 
00268     bool IsDead();
00269 
00273     void SetLogged();
00274 
00278     bool IsLogged();
00279 
00285     void SetAncestor(unsigned ancestorIndex);
00286 
00291     unsigned GetAncestor() const;
00292 
00296     unsigned GetCellId() const;
00297 
00301     static void ResetMaxCellId();
00302 };
00303 
00304 
00305 namespace boost
00306 {
00307 namespace serialization
00308 {
00312 template<class Archive>
00313 inline void save_construct_data(
00314     Archive & ar, const TissueCell * t, const BOOST_PFTO unsigned int file_version)
00315 {
00316     // Save data required to construct instance
00317     const CellType cell_type = t->GetCellType();
00318     const CellMutationState mutation_state = t->GetMutationState();
00319     const AbstractCellCycleModel* const p_cell_cycle_model = t->GetCellCycleModel();
00320     ar << cell_type;
00321     ar << mutation_state;
00322     ar << p_cell_cycle_model;
00323 }
00324 
00328 template<class Archive>
00329 inline void load_construct_data(
00330     Archive & ar, TissueCell * t, const unsigned int file_version)
00331 {
00332     // Retrieve data from archive required to construct new instance
00333     CellType cell_type;
00334     CellMutationState mutation_state;
00335     AbstractCellCycleModel *p_cell_cycle_model;
00336     ar >> cell_type;
00337     ar >> mutation_state;
00338     ar >> p_cell_cycle_model;
00339     bool archiving = true;
00340 
00341     // Invoke inplace constructor to initialise instance
00342     ::new(t)TissueCell(cell_type, mutation_state, p_cell_cycle_model, archiving);
00343 }
00344 }
00345 } // namespace ...
00346 
00347 #endif /*TISSUECELL_HPP_*/

Generated on Tue Aug 4 16:10:21 2009 for Chaste by  doxygen 1.5.5