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
00030
00031
00032
00033
00034
00035
00036 #ifndef CELL_HPP_
00037 #define CELL_HPP_
00038
00039 #include <boost/utility.hpp>
00040 #include <boost/shared_ptr.hpp>
00041 #include <boost/enable_shared_from_this.hpp>
00042
00043 #include "ChasteSerialization.hpp"
00044 #include <boost/serialization/shared_ptr.hpp>
00045
00046 #include "AbstractCellMutationState.hpp"
00047 #include "AbstractCellProliferativeType.hpp"
00048 #include "DefaultCellProliferativeType.hpp"
00049 #include "CellLabel.hpp"
00050 #include "CellAncestor.hpp"
00051 #include "CellId.hpp"
00052 #include "CellData.hpp"
00053
00054 #include "ApoptoticCellProperty.hpp"
00055 #include "AbstractCellCycleModel.hpp"
00056 #include "SimulationTime.hpp"
00057 #include "CellPropertyRegistry.hpp"
00058 #include "CellPropertyCollection.hpp"
00059 #include "SmartPointers.hpp"
00060
00061 class AbstractCellCycleModel;
00062
00063 class Cell;
00064
00066 typedef boost::shared_ptr<Cell> CellPtr;
00067
00075 class Cell : private boost::noncopyable, public boost::enable_shared_from_this<Cell>
00076 {
00077 private:
00078
00080 bool mCanDivide;
00081
00083 friend class boost::serialization::access;
00090 template<class Archive>
00091 void serialize(Archive & archive, const unsigned int version)
00092 {
00093
00094 archive & mCanDivide;
00095 archive & mpCellCycleModel;
00096 archive & mUndergoingApoptosis;
00097 archive & mDeathTime;
00098 archive & mStartOfApoptosisTime;
00099 archive & mApoptosisTime;
00100 archive & mIsDead;
00101 archive & mIsLogged;
00102 }
00103
00104 protected:
00105
00107 CellPropertyCollection mCellPropertyCollection;
00108
00110 AbstractCellCycleModel* mpCellCycleModel;
00111
00113 double mDeathTime;
00114
00116 double mStartOfApoptosisTime;
00117
00119 double mApoptosisTime;
00120
00122 bool mUndergoingApoptosis;
00123
00128 bool mIsDead;
00129
00131 bool mIsLogged;
00132
00133 public:
00134
00144 Cell(boost::shared_ptr<AbstractCellProperty> pMutationState,
00145 AbstractCellCycleModel* pCellCycleModel,
00146 bool archiving=false,
00147 CellPropertyCollection cellPropertyCollection=CellPropertyCollection());
00148
00152 ~Cell();
00153
00157 boost::shared_ptr<AbstractCellProliferativeType> GetCellProliferativeType() const;
00158
00164 void SetCellProliferativeType(boost::shared_ptr<AbstractCellProperty> pProliferativeType);
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 double GetApoptosisTime() const;
00209
00215 void SetApoptosisTime(double apoptosisTime);
00216
00220 boost::shared_ptr<AbstractCellMutationState> GetMutationState() const;
00221
00227 boost::shared_ptr<CellData> GetCellData() const;
00228
00234 void SetMutationState(boost::shared_ptr<AbstractCellProperty> pMutationState);
00235
00239 CellPropertyCollection& rGetCellPropertyCollection();
00240
00244 const CellPropertyCollection& rGetCellPropertyCollection() const;
00245
00254 void AddCellProperty(const boost::shared_ptr<AbstractCellProperty>& rProperty);
00255
00263 template<typename CLASS>
00264 void RemoveCellProperty()
00265 {
00266 bool cell_has_property = false;
00267
00268 for (std::set<boost::shared_ptr<AbstractCellProperty> >::iterator property_iter = mCellPropertyCollection.Begin();
00269 property_iter != mCellPropertyCollection.End();
00270 ++property_iter)
00271 {
00272 if ((*property_iter)->IsType<CLASS>())
00273 {
00274 cell_has_property = true;
00275 (*property_iter)->DecrementCellCount();
00276 break;
00277 }
00278 }
00279
00280 if (cell_has_property)
00281 {
00282 mCellPropertyCollection.RemoveProperty<CLASS>();
00283 }
00284 }
00285
00290 template<typename CLASS>
00291 bool HasCellProperty() const
00292 {
00293 return mCellPropertyCollection.HasProperty<CLASS>();
00294 }
00295
00300 bool ReadyToDivide();
00301
00308 CellPtr Divide();
00309
00316 void StartApoptosis(bool setDeathTime=true);
00317
00322 void Kill();
00323
00327 bool HasApoptosisBegun() const;
00328
00332 double GetTimeUntilDeath() const;
00333
00337 bool IsDead();
00338
00342 void SetLogged();
00343
00347 bool IsLogged();
00348
00354 void SetAncestor(boost::shared_ptr<AbstractCellProperty> pCellAncestor);
00355
00360 unsigned GetAncestor() const;
00361
00365 unsigned GetCellId() const;
00366 };
00367
00368
00369 #include "SerializationExportWrapper.hpp"
00370 CHASTE_CLASS_EXPORT(Cell)
00371
00372 namespace boost
00373 {
00374 namespace serialization
00375 {
00379 template<class Archive>
00380 inline void save_construct_data(
00381 Archive & ar, const Cell * t, const BOOST_PFTO unsigned int file_version)
00382 {
00383
00384 const boost::shared_ptr<AbstractCellMutationState> p_mutation_state = t->GetMutationState();
00385 ar & p_mutation_state;
00386
00387 const AbstractCellCycleModel* const p_cell_cycle_model = t->GetCellCycleModel();
00388 ar & p_cell_cycle_model;
00389
00390 const CellPropertyCollection& r_cell_property_collection = t->rGetCellPropertyCollection();
00391 ar & r_cell_property_collection;
00392 }
00393
00397 template<class Archive>
00398 inline void load_construct_data(
00399 Archive & ar, Cell * t, const unsigned int file_version)
00400 {
00401
00402 boost::shared_ptr<AbstractCellMutationState> p_mutation_state;
00403 ar & p_mutation_state;
00404
00405 AbstractCellCycleModel* p_cell_cycle_model;
00406 ar & p_cell_cycle_model;
00407
00408 bool archiving = true;
00409
00410 CellPropertyCollection cell_property_collection;
00411 ar & cell_property_collection;
00412
00413
00414 ::new(t)Cell(p_mutation_state, p_cell_cycle_model, archiving, cell_property_collection);
00415 }
00416 }
00417 }
00418
00419 #endif