Chaste Commit::ca8ccdedf819b6e02855bc0e8e6f50bdecbc5208
Cell.hpp
1/*
2
3Copyright (c) 2005-2024, University of Oxford.
4All rights reserved.
5
6University of Oxford means the Chancellor, Masters and Scholars of the
7University of Oxford, having an administrative office at Wellington
8Square, Oxford OX1 2JD, UK.
9
10This file is part of Chaste.
11
12Redistribution and use in source and binary forms, with or without
13modification, 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
23THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32OF 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
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#include "CellEdgeData.hpp"
51
52
53#include "AbstractCellCycleModel.hpp"
54#include "AbstractSrnModel.hpp"
55#include "CellPropertyCollection.hpp"
56
57class AbstractCellCycleModel; // Circular definition (cells need to know about cycle models and vice-versa).
58class AbstractSrnModel; // Circular definition (cells need to know about subcellular reaction network models and vice-versa).
59class Cell;
60
62typedef boost::shared_ptr<Cell> CellPtr;
63
77{
79 void operator()(void const *) const
80 {
81 }
82};
83
91class Cell : private boost::noncopyable, public boost::enable_shared_from_this<Cell>
92{
93private:
94
103 template<class Archive>
104 void serialize(Archive & archive, const unsigned int version)
105 {
106 // These first four are also dealt with by {load,save}_construct_data
107 archive & mCanDivide;
108 archive & mpCellCycleModel;
109 archive & mpSrnModel;
110 archive & mUndergoingApoptosis;
111 archive & mDeathTime;
112 archive & mStartOfApoptosisTime;
113 archive & mApoptosisTime;
114 archive & mIsDead;
115 archive & mIsLogged;
116 archive & mHasSrnModel;
117 }
118
119protected:
120
123
126
129
132
135
138
141
144
150
153
156
157public:
158
171 Cell(boost::shared_ptr<AbstractCellProperty> pMutationState,
172 AbstractCellCycleModel* pCellCycleModel,
173 AbstractSrnModel* pSrnModel=nullptr,
174 bool archiving=false,
175 CellPropertyCollection cellPropertyCollection=CellPropertyCollection());
176
180 virtual ~Cell();
181
185 boost::shared_ptr<AbstractCellProliferativeType> GetCellProliferativeType() const;
186
192 void SetCellProliferativeType(boost::shared_ptr<AbstractCellProperty> pProliferativeType);
193
199 void SetBirthTime(double birthTime);
200
206 void SetCellCycleModel(AbstractCellCycleModel* pCellCycleModel);
207
212
217
223 void SetSrnModel(AbstractSrnModel* pSrnModel);
224
229
233 void InitialiseSrnModel();
234
238 double GetAge() const;
239
243 double GetBirthTime() const;
244
248 double GetStartOfApoptosisTime() const;
249
253 double GetApoptosisTime() const;
254
260 void SetApoptosisTime(double apoptosisTime);
261
265 boost::shared_ptr<AbstractCellMutationState> GetMutationState() const;
266
272 boost::shared_ptr<CellData> GetCellData() const;
273
279 boost::shared_ptr<CellEdgeData> GetCellEdgeData() const;
280
286 bool HasCellVecData() const;
287
293 boost::shared_ptr<CellVecData> GetCellVecData() const;
294
300 void SetMutationState(boost::shared_ptr<AbstractCellProperty> pMutationState);
301
306
311
320 void AddCellProperty(const boost::shared_ptr<AbstractCellProperty>& rProperty);
321
329 template<typename CLASS>
331 {
332 bool cell_has_property = false;
333
334 for (std::set<boost::shared_ptr<AbstractCellProperty> >::iterator property_iter = mCellPropertyCollection.Begin();
335 property_iter != mCellPropertyCollection.End();
336 ++property_iter)
337 {
338 if ((*property_iter)->IsType<CLASS>())
339 {
340 cell_has_property = true;
341 (*property_iter)->DecrementCellCount();
342 break;
343 }
344 }
345
346 if (cell_has_property)
347 {
349 }
350 }
351
356 template<typename CLASS>
357 bool HasCellProperty() const
358 {
359 return mCellPropertyCollection.HasProperty<CLASS>();
360 }
361
366 bool ReadyToDivide();
367
374 virtual CellPtr Divide();
375
382 void StartApoptosis(bool setDeathTime=true);
383
388 void Kill();
389
393 bool HasApoptosisBegun() const;
394
398 double GetTimeUntilDeath() const;
399
403 bool IsDead();
404
408 void SetLogged();
409
413 bool IsLogged();
414
420 void SetAncestor(boost::shared_ptr<AbstractCellProperty> pCellAncestor);
421
426 unsigned GetAncestor() const;
427
431 unsigned GetCellId() const;
432
436 bool HasSrnModel() const;
437};
438
439
442
443namespace boost
444{
445namespace serialization
446{
450template<class Archive>
451inline void save_construct_data(
452 Archive & ar, const Cell * t, const unsigned int file_version)
453{
454 // Save data required to construct instance
455 const boost::shared_ptr<AbstractCellMutationState> p_mutation_state = t->GetMutationState();
456 ar & p_mutation_state;
457 const AbstractCellCycleModel* const p_cell_cycle_model = t->GetCellCycleModel();
458 ar & p_cell_cycle_model;
459 const AbstractSrnModel* const p_srn_model = t->GetSrnModel();
460 ar & p_srn_model;
461 const CellPropertyCollection& r_cell_property_collection = t->rGetCellPropertyCollection();
462 ar & r_cell_property_collection;
463}
464
468template<class Archive>
469inline void load_construct_data(
470 Archive & ar, Cell * t, const unsigned int file_version)
471{
472 // Retrieve data from archive required to construct new instance
473 boost::shared_ptr<AbstractCellMutationState> p_mutation_state;
474 ar & p_mutation_state;
475
476 AbstractCellCycleModel* p_cell_cycle_model;
477 ar & p_cell_cycle_model;
478
479 AbstractSrnModel* p_srn_model;
480 ar & p_srn_model;
481
482 bool archiving = true;
483
484 CellPropertyCollection cell_property_collection;
485 ar & cell_property_collection;
486
487 // Invoke inplace constructor to initialize instance
488 ::new(t)Cell(p_mutation_state, p_cell_cycle_model, p_srn_model, archiving, cell_property_collection);
489}
490}
491} // namespace ...
492
493#endif /*CELL_HPP_*/
gcov doesn't like this file...
#define CHASTE_CLASS_EXPORT(T)
bool HasProperty(const boost::shared_ptr< AbstractCellProperty > &rProp) const
Definition Cell.hpp:92
double mDeathTime
Definition Cell.hpp:134
double GetAge() const
Definition Cell.cpp:226
void Kill()
Definition Cell.cpp:411
bool mIsLogged
Definition Cell.hpp:152
void SetLogged()
Definition Cell.cpp:336
bool mHasSrnModel
Definition Cell.hpp:155
bool HasSrnModel() const
Definition Cell.cpp:548
unsigned GetCellId() const
Definition Cell.cpp:459
AbstractSrnModel * GetSrnModel() const
Definition Cell.cpp:216
AbstractCellCycleModel * GetCellCycleModel() const
Definition Cell.cpp:195
void InitialiseSrnModel()
Definition Cell.cpp:221
void RemoveCellProperty()
Definition Cell.hpp:330
AbstractSrnModel * mpSrnModel
Definition Cell.hpp:131
AbstractCellCycleModel * mpCellCycleModel
Definition Cell.hpp:128
bool HasCellVecData() const
Definition Cell.cpp:296
void SetSrnModel(AbstractSrnModel *pSrnModel)
Definition Cell.cpp:205
double mStartOfApoptosisTime
Definition Cell.hpp:137
double GetBirthTime() const
Definition Cell.cpp:231
bool IsDead()
Definition Cell.cpp:398
double GetStartOfApoptosisTime() const
Definition Cell.cpp:372
void AddCellProperty(const boost::shared_ptr< AbstractCellProperty > &rProperty)
Definition Cell.cpp:326
void SetBirthTime(double birthTime)
Definition Cell.cpp:236
boost::shared_ptr< AbstractCellProliferativeType > GetCellProliferativeType() const
Definition Cell.cpp:170
CellPropertyCollection mCellPropertyCollection
Definition Cell.hpp:125
bool mUndergoingApoptosis
Definition Cell.hpp:143
bool mCanDivide
Definition Cell.hpp:122
void SetCellCycleModel(AbstractCellCycleModel *pCellCycleModel)
Definition Cell.cpp:185
boost::shared_ptr< CellData > GetCellData() const
Definition Cell.cpp:270
bool HasCellProperty() const
Definition Cell.hpp:357
bool mIsDead
Definition Cell.hpp:149
bool HasApoptosisBegun() const
Definition Cell.cpp:367
unsigned GetAncestor() const
Definition Cell.cpp:444
boost::shared_ptr< CellVecData > GetCellVecData() const
Definition Cell.cpp:301
virtual ~Cell()
Definition Cell.cpp:145
void serialize(Archive &archive, const unsigned int version)
Definition Cell.hpp:104
bool ReadyToDivide()
Definition Cell.cpp:470
void SetApoptosisTime(double apoptosisTime)
Definition Cell.cpp:382
double GetApoptosisTime() const
Definition Cell.cpp:377
CellPropertyCollection & rGetCellPropertyCollection()
Definition Cell.cpp:316
friend class boost::serialization::access
Definition Cell.hpp:96
boost::shared_ptr< CellEdgeData > GetCellEdgeData() const
Definition Cell.cpp:283
void SetMutationState(boost::shared_ptr< AbstractCellProperty > pMutationState)
Definition Cell.cpp:241
void SetCellProliferativeType(boost::shared_ptr< AbstractCellProperty > pProliferativeType)
Definition Cell.cpp:155
double mApoptosisTime
Definition Cell.hpp:140
void SetAncestor(boost::shared_ptr< AbstractCellProperty > pCellAncestor)
Definition Cell.cpp:423
void StartApoptosis(bool setDeathTime=true)
Definition Cell.cpp:346
double GetTimeUntilDeath() const
Definition Cell.cpp:388
void InitialiseCellCycleModel()
Definition Cell.cpp:200
virtual CellPtr Divide()
Definition Cell.cpp:487
boost::shared_ptr< AbstractCellMutationState > GetMutationState() const
Definition Cell.cpp:255
bool IsLogged()
Definition Cell.cpp:341
void operator()(void const *) const
Definition Cell.hpp:79