Chaste  Release::3.4
Cell.hpp
1 /*
2 
3 Copyright (c) 2005-2016, University of Oxford.
4 All rights reserved.
5 
6 University of Oxford means the Chancellor, Masters and Scholars of the
7 University of Oxford, having an administrative office at Wellington
8 Square, Oxford OX1 2JD, UK.
9 
10 This file is part of Chaste.
11 
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions are met:
14  * Redistributions of source code must retain the above copyright notice,
15  this list of conditions and the following disclaimer.
16  * Redistributions in binary form must reproduce the above copyright notice,
17  this list of conditions and the following disclaimer in the documentation
18  and/or other materials provided with the distribution.
19  * Neither the name of the University of Oxford nor the names of its
20  contributors may be used to endorse or promote products derived from this
21  software without specific prior written permission.
22 
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 
34 */
35 
36 #ifndef CELL_HPP_
37 #define CELL_HPP_
38 
39 #include <boost/utility.hpp>
40 #include <boost/shared_ptr.hpp>
41 #include <boost/enable_shared_from_this.hpp>
42 
43 #include "ChasteSerialization.hpp"
44 #include <boost/serialization/shared_ptr.hpp>
45 
46 #include "AbstractCellMutationState.hpp"
47 #include "AbstractCellProliferativeType.hpp"
48 #include "DefaultCellProliferativeType.hpp"
49 #include "CellLabel.hpp"
50 #include "CellAncestor.hpp"
51 #include "CellId.hpp"
52 #include "CellData.hpp"
53 #include "CellVecData.hpp"
54 
55 #include "ApoptoticCellProperty.hpp"
56 #include "AbstractCellCycleModel.hpp"
57 #include "AbstractSrnModel.hpp"
58 #include "SimulationTime.hpp"
59 #include "CellPropertyRegistry.hpp"
60 #include "CellPropertyCollection.hpp"
61 #include "SmartPointers.hpp"
62 
63 class AbstractCellCycleModel; // Circular definition (cells need to know about cycle models and vice-versa).
64 class AbstractSrnModel; // Circular definition (cells need to know about subcellular reaction network models and vice-versa).
65 class Cell;
66 
68 typedef boost::shared_ptr<Cell> CellPtr;
69 
77 class Cell : private boost::noncopyable, public boost::enable_shared_from_this<Cell>
78 {
79 private:
80 
82  bool mCanDivide;
83 
92  template<class Archive>
93  void serialize(Archive & archive, const unsigned int version)
94  {
95  // These first four are also dealt with by {load,save}_construct_data
96  archive & mCanDivide;
97  archive & mpCellCycleModel;
98  archive & mpSrnModel;
99  archive & mUndergoingApoptosis;
100  archive & mDeathTime;
101  archive & mStartOfApoptosisTime;
102  archive & mApoptosisTime;
103  archive & mIsDead;
104  archive & mIsLogged;
105  }
106 
107 protected:
108 
111 
114 
117 
119  double mDeathTime;
120 
123 
126 
129 
134  bool mIsDead;
135 
137  bool mIsLogged;
138 
139 public:
140 
153  Cell(boost::shared_ptr<AbstractCellProperty> pMutationState,
154  AbstractCellCycleModel* pCellCycleModel,
155  AbstractSrnModel* pSrnModel=NULL,
156  bool archiving=false,
157  CellPropertyCollection cellPropertyCollection=CellPropertyCollection());
158 
162  ~Cell();
163 
167  boost::shared_ptr<AbstractCellProliferativeType> GetCellProliferativeType() const;
168 
174  void SetCellProliferativeType(boost::shared_ptr<AbstractCellProperty> pProliferativeType);
175 
181  void SetBirthTime(double birthTime);
182 
188  void SetCellCycleModel(AbstractCellCycleModel* pCellCycleModel);
189 
194 
199 
205  void SetSrnModel(AbstractSrnModel* pSrnModel);
206 
210  AbstractSrnModel* GetSrnModel() const;
211 
215  void InitialiseSrnModel();
216 
220  double GetAge() const;
221 
225  double GetBirthTime() const;
226 
230  double GetStartOfApoptosisTime() const;
231 
235  double GetApoptosisTime() const;
236 
242  void SetApoptosisTime(double apoptosisTime);
243 
247  boost::shared_ptr<AbstractCellMutationState> GetMutationState() const;
248 
254  boost::shared_ptr<CellData> GetCellData() const;
255 
261  bool HasCellVecData() const;
262 
268  boost::shared_ptr<CellVecData> GetCellVecData() const;
269 
275  void SetMutationState(boost::shared_ptr<AbstractCellProperty> pMutationState);
276 
281 
286 
295  void AddCellProperty(const boost::shared_ptr<AbstractCellProperty>& rProperty);
296 
304  template<typename CLASS>
306  {
307  bool cell_has_property = false;
308 
309  for (std::set<boost::shared_ptr<AbstractCellProperty> >::iterator property_iter = mCellPropertyCollection.Begin();
310  property_iter != mCellPropertyCollection.End();
311  ++property_iter)
312  {
313  if ((*property_iter)->IsType<CLASS>())
314  {
315  cell_has_property = true;
316  (*property_iter)->DecrementCellCount();
317  break;
318  }
319  }
320 
321  if (cell_has_property)
322  {
324  }
325  }
326 
331  template<typename CLASS>
332  bool HasCellProperty() const
333  {
334  return mCellPropertyCollection.HasProperty<CLASS>();
335  }
336 
341  bool ReadyToDivide();
342 
349  CellPtr Divide();
350 
357  void StartApoptosis(bool setDeathTime=true);
358 
363  void Kill();
364 
368  bool HasApoptosisBegun() const;
369 
373  double GetTimeUntilDeath() const;
374 
378  bool IsDead();
379 
383  void SetLogged();
384 
388  bool IsLogged();
389 
395  void SetAncestor(boost::shared_ptr<AbstractCellProperty> pCellAncestor);
396 
401  unsigned GetAncestor() const;
402 
406  unsigned GetCellId() const;
407 };
408 
409 
412 
413 namespace boost
414 {
415 namespace serialization
416 {
420 template<class Archive>
421 inline void save_construct_data(
422  Archive & ar, const Cell * t, const unsigned int file_version)
423 {
424  // Save data required to construct instance
425  const boost::shared_ptr<AbstractCellMutationState> p_mutation_state = t->GetMutationState();
426  ar & p_mutation_state;
427 
428  const AbstractCellCycleModel* const p_cell_cycle_model = t->GetCellCycleModel();
429  ar & p_cell_cycle_model;
430 
431  const AbstractSrnModel* const p_srn_model = t->GetSrnModel();
432  ar & p_srn_model;
433 
434  const CellPropertyCollection& r_cell_property_collection = t->rGetCellPropertyCollection();
435  ar & r_cell_property_collection;
436 }
437 
441 template<class Archive>
442 inline void load_construct_data(
443  Archive & ar, Cell * t, const unsigned int file_version)
444 {
445  // Retrieve data from archive required to construct new instance
446  boost::shared_ptr<AbstractCellMutationState> p_mutation_state;
447  ar & p_mutation_state;
448 
449  AbstractCellCycleModel* p_cell_cycle_model;
450  ar & p_cell_cycle_model;
451 
452  AbstractSrnModel* p_srn_model;
453  ar & p_srn_model;
454 
455  bool archiving = true;
456 
457  CellPropertyCollection cell_property_collection;
458  ar & cell_property_collection;
459 
460  // Invoke inplace constructor to initialize instance
461  ::new(t)Cell(p_mutation_state, p_cell_cycle_model, p_srn_model, archiving, cell_property_collection);
462 }
463 }
464 } // namespace ...
465 
466 #endif /*CELL_HPP_*/
void InitialiseSrnModel()
Definition: Cell.cpp:223
AbstractCellCycleModel * GetCellCycleModel() const
Definition: Cell.cpp:198
bool ReadyToDivide()
Definition: Cell.cpp:459
Definition: Cell.hpp:77
double GetAge() const
Definition: Cell.cpp:228
void serialize(Archive &archive, const unsigned int version)
Definition: Cell.hpp:93
double GetBirthTime() const
Definition: Cell.cpp:233
double GetTimeUntilDeath() const
Definition: Cell.cpp:377
void SetLogged()
Definition: Cell.cpp:325
void Kill()
Definition: Cell.cpp:400
void InitialiseCellCycleModel()
Definition: Cell.cpp:203
bool mCanDivide
Definition: Cell.hpp:82
void SetCellCycleModel(AbstractCellCycleModel *pCellCycleModel)
Definition: Cell.cpp:188
AbstractSrnModel * mpSrnModel
Definition: Cell.hpp:116
double mDeathTime
Definition: Cell.hpp:119
double mApoptosisTime
Definition: Cell.hpp:125
double GetStartOfApoptosisTime() const
Definition: Cell.cpp:361
unsigned GetAncestor() const
Definition: Cell.cpp:433
boost::shared_ptr< AbstractCellProliferativeType > GetCellProliferativeType() const
Definition: Cell.cpp:173
void AddCellProperty(const boost::shared_ptr< AbstractCellProperty > &rProperty)
Definition: Cell.cpp:315
void SetApoptosisTime(double apoptosisTime)
Definition: Cell.cpp:371
boost::shared_ptr< CellVecData > GetCellVecData() const
Definition: Cell.cpp:290
bool mIsLogged
Definition: Cell.hpp:137
bool mUndergoingApoptosis
Definition: Cell.hpp:128
double GetApoptosisTime() const
Definition: Cell.cpp:366
bool IsDead()
Definition: Cell.cpp:387
CellPropertyCollection & rGetCellPropertyCollection()
Definition: Cell.cpp:305
void SetCellProliferativeType(boost::shared_ptr< AbstractCellProperty > pProliferativeType)
Definition: Cell.cpp:158
bool HasApoptosisBegun() const
Definition: Cell.cpp:356
AbstractCellCycleModel * mpCellCycleModel
Definition: Cell.hpp:113
~Cell()
Definition: Cell.cpp:148
AbstractSrnModel * GetSrnModel() const
Definition: Cell.cpp:218
void StartApoptosis(bool setDeathTime=true)
Definition: Cell.cpp:335
bool HasProperty(const boost::shared_ptr< AbstractCellProperty > &rProp) const
CellPtr Divide()
Definition: Cell.cpp:475
friend class boost::serialization::access
Definition: Cell.hpp:85
bool mIsDead
Definition: Cell.hpp:134
bool HasCellVecData() const
Definition: Cell.cpp:285
unsigned GetCellId() const
Definition: Cell.cpp:448
CellPropertyCollection mCellPropertyCollection
Definition: Cell.hpp:110
boost::shared_ptr< CellData > GetCellData() const
Definition: Cell.cpp:272
void SetMutationState(boost::shared_ptr< AbstractCellProperty > pMutationState)
Definition: Cell.cpp:243
#define CHASTE_CLASS_EXPORT(T)
void SetBirthTime(double birthTime)
Definition: Cell.cpp:238
bool IsLogged()
Definition: Cell.cpp:330
void SetAncestor(boost::shared_ptr< AbstractCellProperty > pCellAncestor)
Definition: Cell.cpp:412
void SetSrnModel(AbstractSrnModel *pSrnModel)
Definition: Cell.cpp:208
double mStartOfApoptosisTime
Definition: Cell.hpp:122
void RemoveCellProperty()
Definition: Cell.hpp:305
bool HasCellProperty() const
Definition: Cell.hpp:332
Cell(boost::shared_ptr< AbstractCellProperty > pMutationState, AbstractCellCycleModel *pCellCycleModel, AbstractSrnModel *pSrnModel=NULL, bool archiving=false, CellPropertyCollection cellPropertyCollection=CellPropertyCollection())
Definition: Cell.cpp:61
boost::shared_ptr< AbstractCellMutationState > GetMutationState() const
Definition: Cell.cpp:257