Cell.hpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef CELL_HPP_
00030 #define CELL_HPP_
00031
00032 #include <boost/utility.hpp>
00033 #include <boost/shared_ptr.hpp>
00034 #include <boost/enable_shared_from_this.hpp>
00035
00036 #include "ChasteSerialization.hpp"
00037 #include <boost/serialization/shared_ptr.hpp>
00038
00039 #include "CellProliferativeTypes.hpp"
00040 #include "AbstractCellMutationState.hpp"
00041 #include "CellLabel.hpp"
00042 #include "ApoptoticCellProperty.hpp"
00043 #include "AbstractCellCycleModel.hpp"
00044 #include "SimulationTime.hpp"
00045 #include "CellPropertyRegistry.hpp"
00046 #include "CellPropertyCollection.hpp"
00047
00048 class AbstractCellCycleModel;
00049
00050 class Cell;
00051
00053 typedef boost::shared_ptr<Cell> CellPtr;
00054
00062 class Cell : boost::noncopyable, public boost::enable_shared_from_this<Cell>
00063 {
00064 private:
00065
00067 bool mCanDivide;
00068
00070 friend class boost::serialization::access;
00077 template<class Archive>
00078 void serialize(Archive & archive, const unsigned int version)
00079 {
00080
00081 archive & mCanDivide;
00082 archive & mpCellCycleModel;
00083 archive & mUndergoingApoptosis;
00084 archive & mDeathTime;
00085 archive & mStartOfApoptosisTime;
00086 archive & mApoptosisTime;
00087 archive & mIsDead;
00088 archive & mIsLogged;
00089 archive & mAncestor;
00090 archive & mCellId;
00091 archive & mMaxCellId;
00092 }
00093
00094 protected:
00095
00097 CellPropertyCollection mCellPropertyCollection;
00098
00100 AbstractCellCycleModel* mpCellCycleModel;
00101
00103 unsigned mAncestor;
00104
00106 unsigned mCellId;
00107
00109 static unsigned mMaxCellId;
00110
00112 double mDeathTime;
00113
00115 double mStartOfApoptosisTime;
00116
00118 double mApoptosisTime;
00119
00121 bool mUndergoingApoptosis;
00122
00127 bool mIsDead;
00128
00130 bool mIsLogged;
00131
00132 public:
00133
00143 Cell(boost::shared_ptr<AbstractCellProperty> pMutationState,
00144 AbstractCellCycleModel* pCellCycleModel,
00145 bool archiving=false,
00146 CellPropertyCollection cellPropertyCollection=CellPropertyCollection());
00147
00151 ~Cell();
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 double GetStartOfApoptosisTime() const;
00191
00195 double GetApoptosisTime() const;
00196
00202 void SetApoptosisTime(double apoptosisTime);
00203
00207 boost::shared_ptr<AbstractCellMutationState> GetMutationState() const;
00208
00214 void SetMutationState(boost::shared_ptr<AbstractCellProperty> pMutationState);
00215
00219 CellPropertyCollection& rGetCellPropertyCollection();
00220
00224 const CellPropertyCollection& rGetCellPropertyCollection() const;
00225
00234 void AddCellProperty(const boost::shared_ptr<AbstractCellProperty>& rProperty);
00235
00243 template<typename CLASS>
00244 void RemoveCellProperty()
00245 {
00246 bool cell_has_property = false;
00247
00248 for (std::set<boost::shared_ptr<AbstractCellProperty> >::iterator property_iter = mCellPropertyCollection.Begin();
00249 property_iter != mCellPropertyCollection.End();
00250 ++property_iter)
00251 {
00252 if ((*property_iter)->IsType<CLASS>())
00253 {
00254 cell_has_property = true;
00255 (*property_iter)->DecrementCellCount();
00256 break;
00257 }
00258 }
00259
00260 if (cell_has_property)
00261 {
00262 mCellPropertyCollection.RemoveProperty<CLASS>();
00263 }
00264 }
00265
00270 template<typename CLASS>
00271 bool HasCellProperty() const
00272 {
00273 return mCellPropertyCollection.HasProperty<CLASS>();
00274 }
00275
00280 bool ReadyToDivide();
00281
00288 CellPtr Divide();
00289
00296 void StartApoptosis(bool setDeathTime=true);
00297
00302 void Kill();
00303
00307 bool HasApoptosisBegun() const;
00308
00312 double GetTimeUntilDeath() const;
00313
00317 bool IsDead();
00318
00322 void SetLogged();
00323
00327 bool IsLogged();
00328
00334 void SetAncestor(unsigned ancestorIndex);
00335
00340 unsigned GetAncestor() const;
00341
00345 unsigned GetCellId() const;
00346
00350 static void ResetMaxCellId();
00351 };
00352
00353
00354 #include "SerializationExportWrapper.hpp"
00355 CHASTE_CLASS_EXPORT(Cell)
00356
00357 namespace boost
00358 {
00359 namespace serialization
00360 {
00364 template<class Archive>
00365 inline void save_construct_data(
00366 Archive & ar, const Cell * t, const BOOST_PFTO unsigned int file_version)
00367 {
00368
00369 const boost::shared_ptr<AbstractCellMutationState> p_mutation_state = t->GetMutationState();
00370 ar & p_mutation_state;
00371
00372 const AbstractCellCycleModel* const p_cell_cycle_model = t->GetCellCycleModel();
00373 ar & p_cell_cycle_model;
00374
00375 const CellPropertyCollection& r_cell_property_collection = t->rGetCellPropertyCollection();
00376 ar & r_cell_property_collection;
00377 }
00378
00382 template<class Archive>
00383 inline void load_construct_data(
00384 Archive & ar, Cell * t, const unsigned int file_version)
00385 {
00386
00387 boost::shared_ptr<AbstractCellMutationState> p_mutation_state;
00388 ar & p_mutation_state;
00389
00390 AbstractCellCycleModel* p_cell_cycle_model;
00391 ar & p_cell_cycle_model;
00392
00393 bool archiving = true;
00394
00395 CellPropertyCollection cell_property_collection;
00396 ar & cell_property_collection;
00397
00398
00399 ::new(t)Cell(p_mutation_state, p_cell_cycle_model, archiving, cell_property_collection);
00400 }
00401 }
00402 }
00403
00404 #endif