TissueCell.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2010
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 "ChasteSerialization.hpp"
00032 #include <boost/shared_ptr.hpp>
00033 #include <boost/serialization/shared_ptr.hpp>
00034 
00035 #include "Element.hpp"
00036 #include "CellProliferativeTypes.hpp"
00037 #include "AbstractCellMutationState.hpp"
00038 #include "AbstractCellCycleModel.hpp"
00039 #include "SimulationTime.hpp"
00040 
00041 class AbstractCellCycleModel; // Circular definition (cells need to know about cycle models and vice-versa).
00042 
00043 
00051 class TissueCell
00052 {
00053 private:
00054 
00056     bool mCanDivide;
00057 
00059     friend class boost::serialization::access;
00066     template<class Archive>
00067     void serialize(Archive & archive, const unsigned int version)
00068     {
00069         // If Archive is an output archive, then '&' resolves to '<<'
00070         // If Archive is an input archive, then '&' resolves to '>>'
00071         // These first four are also dealt with by {load,save}_construct_data
00072         archive & mCanDivide;
00073         archive & mCellProliferativeType;
00074         archive & mpMutationState;
00075         archive & mpCellCycleModel;
00076         archive & mUndergoingApoptosis;
00077         archive & mDeathTime;
00078         archive & mStartOfApoptosisTime;
00079         archive & mIsDead;
00080         archive & mIsLogged;
00081         archive & mAncestor;
00082         archive & mCellId;
00083         archive & mMaxCellId;
00084     }
00085 
00086 protected:
00087 
00088     // NB - if you add any member variables, make sure CommonCopy includes them.
00089 
00091     CellProliferativeType mCellProliferativeType;
00092 
00094     boost::shared_ptr<AbstractCellMutationState> mpMutationState;
00095 
00097     AbstractCellCycleModel* mpCellCycleModel;
00098 
00100     unsigned mAncestor;
00101 
00103     unsigned mCellId;
00104 
00106     static unsigned mMaxCellId;
00107 
00109     double mDeathTime;
00110 
00112     double mStartOfApoptosisTime;
00113 
00115     bool mUndergoingApoptosis;
00116 
00121     bool mIsDead;
00122 
00124     bool mIsLogged;
00125 
00131     void CommonCopy(const TissueCell& rOtherCell);
00132 
00133 public:
00134 
00143     TissueCell(CellProliferativeType cellType,
00144                boost::shared_ptr<AbstractCellMutationState> pMutationState,
00145                AbstractCellCycleModel* pCellCycleModel,
00146                bool archiving = false);
00147 
00151     ~TissueCell();
00152 
00157     TissueCell(const TissueCell& rOtherCell);
00158 
00164     TissueCell& operator=(const TissueCell& rOtherCell);
00165 
00171     void SetBirthTime(double birthTime);
00172 
00178     void SetCellCycleModel(AbstractCellCycleModel* pCellCycleModel);
00179 
00183     AbstractCellCycleModel* GetCellCycleModel() const;
00184 
00188     void InitialiseCellCycleModel();
00189 
00193     double GetAge() const;
00194 
00198     double GetBirthTime() const;
00199 
00203     double GetStartOfApoptosisTime() const;
00204 
00208     CellProliferativeType GetCellProliferativeType() const;
00209 
00215     void SetCellProliferativeType(CellProliferativeType cellType);
00216 
00220     boost::shared_ptr<AbstractCellMutationState> GetMutationState() const;
00221 
00227     void SetMutationState(boost::shared_ptr<AbstractCellMutationState> pMutationState);
00228 
00233     bool ReadyToDivide();
00234 
00241     TissueCell Divide();
00242 
00249     void StartApoptosis(bool setDeathTime=true);
00250 
00255     void Kill();
00256 
00260     bool HasApoptosisBegun() const;
00261 
00265     double GetTimeUntilDeath() const;
00266 
00270     bool IsDead();
00271 
00275     void SetLogged();
00276 
00280     bool IsLogged();
00281 
00287     void SetAncestor(unsigned ancestorIndex);
00288 
00293     unsigned GetAncestor() const;
00294 
00298     unsigned GetCellId() const;
00299 
00303     static void ResetMaxCellId();
00304 };
00305 
00306 
00307 #include "SerializationExportWrapper.hpp"
00308 CHASTE_CLASS_EXPORT(TissueCell);
00309 
00310 namespace boost
00311 {
00312 namespace serialization
00313 {
00317 template<class Archive>
00318 inline void save_construct_data(
00319     Archive & ar, const TissueCell * t, const BOOST_PFTO unsigned int file_version)
00320 {
00321     // Save data required to construct instance
00322     const CellProliferativeType cell_type = t->GetCellProliferativeType();
00323     const boost::shared_ptr<AbstractCellMutationState> p_mutation_state = t->GetMutationState();
00324 
00325     const AbstractCellCycleModel* const p_cell_cycle_model = t->GetCellCycleModel();
00326     ar << cell_type;
00327     ar << p_mutation_state;
00328     ar << p_cell_cycle_model;
00329 }
00330 
00334 template<class Archive>
00335 inline void load_construct_data(
00336     Archive & ar, TissueCell * t, const unsigned int file_version)
00337 {
00338     // Retrieve data from archive required to construct new instance
00339     CellProliferativeType cell_type;
00340     boost::shared_ptr<AbstractCellMutationState> p_mutation_state;
00341     AbstractCellCycleModel* p_cell_cycle_model;
00342 
00343     ar >> cell_type;
00344     ar >> p_mutation_state;
00345     ar >> p_cell_cycle_model;
00346     bool archiving = true;
00347 
00348     // Invoke inplace constructor to initialize instance
00349     ::new(t)TissueCell(cell_type, p_mutation_state, p_cell_cycle_model, archiving);
00350 }
00351 }
00352 } // namespace ...
00353 
00354 #endif /*TISSUECELL_HPP_*/

Generated by  doxygen 1.6.2