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 #include "CancerParameters.hpp"
00039 
00040 class AbstractCellCycleModel; // Circular definition (cells need to know about cycle models and vice-versa).
00041 
00042 
00050 class TissueCell
00051 {
00052 private:
00053 
00055     bool mCanDivide;
00056 
00058     friend class boost::serialization::access;
00065     template<class Archive>
00066     void serialize(Archive & archive, const unsigned int version)
00067     {
00068         // If Archive is an output archive, then '&' resolves to '<<'
00069         // If Archive is an input archive, then '&' resolves to '>>'
00070         // These first four are also dealt with by {load,save}_construct_data
00071         archive & mCanDivide;
00072         archive & mCellType;
00073         archive & mMutationState;
00074         archive & mpCellCycleModel;
00075         archive & mUndergoingApoptosis;
00076         archive & mDeathTime;
00077         archive & mIsDead;
00078         archive & mIsLogged;
00079         archive & mAncestor;
00080     }
00081 
00082 protected:
00083 
00084     // NB - if you add any member variables, make sure CommonCopy includes them.
00085     
00087     CellType mCellType;
00088     
00090     CellMutationState mMutationState;
00091     
00093     AbstractCellCycleModel* mpCellCycleModel;
00094     
00096     unsigned mAncestor;
00097     
00099     double mDeathTime;
00100     
00102     bool mUndergoingApoptosis;
00103     
00105     bool mIsDead;
00106     
00108     bool mIsLogged;
00109     
00114     void CommonCopy(const TissueCell &otherCell);
00115 
00116 public:
00117 
00126     TissueCell(CellType cellType,
00127                CellMutationState mutationState,
00128                AbstractCellCycleModel* pCellCycleModel,
00129                bool archiving = false);
00130 
00134     ~TissueCell();
00135 
00140     TissueCell(const TissueCell &otherCell);
00141 
00151     TissueCell& operator=(const TissueCell &otherCell);
00152 
00158     void SetBirthTime(double birthTime);
00159 
00165     void SetCellCycleModel(AbstractCellCycleModel* pCellCycleModel);
00166     
00170     AbstractCellCycleModel* GetCellCycleModel() const;
00171 
00175     void InitialiseCellCycleModel();
00176 
00180     double GetAge() const;
00181     
00185     double GetBirthTime() const;
00186 
00190     CellType GetCellType() const;
00191 
00197     void SetCellType(CellType cellType);
00198     
00202     CellMutationState GetMutationState() const;
00203 
00209     void SetMutationState(CellMutationState mutationState);
00210 
00215     bool ReadyToDivide();
00216 
00223     TissueCell Divide();
00224 
00228     void StartApoptosis();
00229     
00234     void Kill();
00235     
00239     bool HasApoptosisBegun() const;
00240     
00244     double TimeUntilDeath() const;
00245 
00249     bool IsDead() const;
00250 
00254     void SetLogged();
00255     
00259     bool IsLogged();
00260 
00265     void SetAncestor(unsigned ancestorIndex);
00266     
00271     unsigned GetAncestor() const;
00272 };
00273 
00274 
00275 namespace boost
00276 {
00277 namespace serialization
00278 {
00282 template<class Archive>
00283 inline void save_construct_data(
00284     Archive & ar, const TissueCell * t, const BOOST_PFTO unsigned int file_version)
00285 {
00286     // Save data required to construct instance
00287     const CellType cell_type = t->GetCellType();
00288     const CellMutationState mutation_state = t->GetMutationState();
00289     const AbstractCellCycleModel* const p_cell_cycle_model = t->GetCellCycleModel();
00290     ar << cell_type;
00291     ar << mutation_state;
00292     ar << p_cell_cycle_model;
00293 }
00294 
00298 template<class Archive>
00299 inline void load_construct_data(
00300     Archive & ar, TissueCell * t, const unsigned int file_version)
00301 {
00302     // Retrieve data from archive required to construct new instance
00303     CellType cell_type;
00304     CellMutationState mutation_state;
00305     AbstractCellCycleModel* p_cell_cycle_model;
00306     ar >> cell_type;
00307     ar >> mutation_state;
00308     ar >> p_cell_cycle_model;
00309     bool archiving = true;
00310     
00311     // Invoke inplace constructor to initialise instance
00312     ::new(t)TissueCell(cell_type, mutation_state, p_cell_cycle_model, archiving);
00313 }
00314 }
00315 } // namespace ...
00316 
00317 #endif /*TISSUECELL_HPP_*/

Generated on Wed Mar 18 12:51:50 2009 for Chaste by  doxygen 1.5.5