Chaste  Release::2017.1
Cell.hpp
1 /*
2 
3 Copyright (c) 2005-2017, 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 "CellData.hpp"
49 #include "CellVecData.hpp"
50 
51 #include "AbstractCellCycleModel.hpp"
52 #include "AbstractSrnModel.hpp"
53 #include "CellPropertyCollection.hpp"
54 
55 class AbstractCellCycleModel; // Circular definition (cells need to know about cycle models and vice-versa).
56 class AbstractSrnModel; // Circular definition (cells need to know about subcellular reaction network models and vice-versa).
57 class Cell;
58 
60 typedef boost::shared_ptr<Cell> CellPtr;
61 
75 {
77  void operator()(void const *) const
78  {
79  }
80 };
81 
89 class Cell : private boost::noncopyable, public boost::enable_shared_from_this<Cell>
90 {
91 private:
92 
94  bool mCanDivide;
95 
97  friend class boost::serialization::access;
104  template<class Archive>
105  void serialize(Archive & archive, const unsigned int version)
106  {
107  // These first four are also dealt with by {load,save}_construct_data
108  archive & mCanDivide;
109  archive & mpCellCycleModel;
110  archive & mpSrnModel;
111  archive & mUndergoingApoptosis;
112  archive & mDeathTime;
113  archive & mStartOfApoptosisTime;
114  archive & mApoptosisTime;
115  archive & mIsDead;
116  archive & mIsLogged;
117  }
118 
119 protected:
120 
123 
126 
129 
131  double mDeathTime;
132 
135 
138 
141 
146  bool mIsDead;
147 
149  bool mIsLogged;
150 
151 public:
152 
165  Cell(boost::shared_ptr<AbstractCellProperty> pMutationState,
166  AbstractCellCycleModel* pCellCycleModel,
167  AbstractSrnModel* pSrnModel=nullptr,
168  bool archiving=false,
169  CellPropertyCollection cellPropertyCollection=CellPropertyCollection());
170 
174  ~Cell();
175 
179  boost::shared_ptr<AbstractCellProliferativeType> GetCellProliferativeType() const;
180 
186  void SetCellProliferativeType(boost::shared_ptr<AbstractCellProperty> pProliferativeType);
187 
193  void SetBirthTime(double birthTime);
194 
200  void SetCellCycleModel(AbstractCellCycleModel* pCellCycleModel);
201 
205  AbstractCellCycleModel* GetCellCycleModel() const;
206 
210  void InitialiseCellCycleModel();
211 
217  void SetSrnModel(AbstractSrnModel* pSrnModel);
218 
222  AbstractSrnModel* GetSrnModel() const;
223 
227  void InitialiseSrnModel();
228 
232  double GetAge() const;
233 
237  double GetBirthTime() const;
238 
242  double GetStartOfApoptosisTime() const;
243 
247  double GetApoptosisTime() const;
248 
254  void SetApoptosisTime(double apoptosisTime);
255 
259  boost::shared_ptr<AbstractCellMutationState> GetMutationState() const;
260 
266  boost::shared_ptr<CellData> GetCellData() const;
267 
273  bool HasCellVecData() const;
274 
280  boost::shared_ptr<CellVecData> GetCellVecData() const;
281 
287  void SetMutationState(boost::shared_ptr<AbstractCellProperty> pMutationState);
288 
292  CellPropertyCollection& rGetCellPropertyCollection();
293 
297  const CellPropertyCollection& rGetCellPropertyCollection() const;
298 
307  void AddCellProperty(const boost::shared_ptr<AbstractCellProperty>& rProperty);
308 
316  template<typename CLASS>
318  {
319  bool cell_has_property = false;
320 
321  for (std::set<boost::shared_ptr<AbstractCellProperty> >::iterator property_iter = mCellPropertyCollection.Begin();
322  property_iter != mCellPropertyCollection.End();
323  ++property_iter)
324  {
325  if ((*property_iter)->IsType<CLASS>())
326  {
327  cell_has_property = true;
328  (*property_iter)->DecrementCellCount();
329  break;
330  }
331  }
332 
333  if (cell_has_property)
334  {
335  mCellPropertyCollection.RemoveProperty<CLASS>();
336  }
337  }
338 
343  template<typename CLASS>
344  bool HasCellProperty() const
345  {
346  return mCellPropertyCollection.HasProperty<CLASS>();
347  }
348 
353  bool ReadyToDivide();
354 
361  CellPtr Divide();
362 
369  void StartApoptosis(bool setDeathTime=true);
370 
375  void Kill();
376 
380  bool HasApoptosisBegun() const;
381 
385  double GetTimeUntilDeath() const;
386 
390  bool IsDead();
391 
395  void SetLogged();
396 
400  bool IsLogged();
401 
407  void SetAncestor(boost::shared_ptr<AbstractCellProperty> pCellAncestor);
408 
413  unsigned GetAncestor() const;
414 
418  unsigned GetCellId() const;
419 };
420 
421 
424 
425 namespace boost
426 {
427 namespace serialization
428 {
432 template<class Archive>
433 inline void save_construct_data(
434  Archive & ar, const Cell * t, const unsigned int file_version)
435 {
436  // Save data required to construct instance
437  const boost::shared_ptr<AbstractCellMutationState> p_mutation_state = t->GetMutationState();
438  ar & p_mutation_state;
439 
440  const AbstractCellCycleModel* const p_cell_cycle_model = t->GetCellCycleModel();
441  ar & p_cell_cycle_model;
442 
443  const AbstractSrnModel* const p_srn_model = t->GetSrnModel();
444  ar & p_srn_model;
445 
446  const CellPropertyCollection& r_cell_property_collection = t->rGetCellPropertyCollection();
447  ar & r_cell_property_collection;
448 }
449 
453 template<class Archive>
454 inline void load_construct_data(
455  Archive & ar, Cell * t, const unsigned int file_version)
456 {
457  // Retrieve data from archive required to construct new instance
458  boost::shared_ptr<AbstractCellMutationState> p_mutation_state;
459  ar & p_mutation_state;
460 
461  AbstractCellCycleModel* p_cell_cycle_model;
462  ar & p_cell_cycle_model;
463 
464  AbstractSrnModel* p_srn_model;
465  ar & p_srn_model;
466 
467  bool archiving = true;
468 
469  CellPropertyCollection cell_property_collection;
470  ar & cell_property_collection;
471 
472  // Invoke inplace constructor to initialize instance
473  ::new(t)Cell(p_mutation_state, p_cell_cycle_model, p_srn_model, archiving, cell_property_collection);
474 }
475 }
476 } // namespace ...
477 
478 #endif /*CELL_HPP_*/
AbstractCellCycleModel * GetCellCycleModel() const
Definition: Cell.cpp:183
Definition: Cell.hpp:89
void serialize(Archive &archive, const unsigned int version)
Definition: Cell.hpp:105
bool mCanDivide
Definition: Cell.hpp:94
AbstractSrnModel * mpSrnModel
Definition: Cell.hpp:128
double mDeathTime
Definition: Cell.hpp:131
double mApoptosisTime
Definition: Cell.hpp:137
void operator()(void const *) const
Definition: Cell.hpp:77
bool mIsLogged
Definition: Cell.hpp:149
bool mUndergoingApoptosis
Definition: Cell.hpp:140
CellPropertyCollection & rGetCellPropertyCollection()
Definition: Cell.cpp:290
AbstractCellCycleModel * mpCellCycleModel
Definition: Cell.hpp:125
AbstractSrnModel * GetSrnModel() const
Definition: Cell.cpp:203
bool HasProperty(const boost::shared_ptr< AbstractCellProperty > &rProp) const
bool mIsDead
Definition: Cell.hpp:146
CellPropertyCollection mCellPropertyCollection
Definition: Cell.hpp:122
#define CHASTE_CLASS_EXPORT(T)
double mStartOfApoptosisTime
Definition: Cell.hpp:134
void RemoveCellProperty()
Definition: Cell.hpp:317
gcov doesn&#39;t like this file...
bool HasCellProperty() const
Definition: Cell.hpp:344
boost::shared_ptr< AbstractCellMutationState > GetMutationState() const
Definition: Cell.cpp:242