Cell.hpp

00001 /*
00002 
00003 Copyright (c) 2005-2015, University of Oxford.
00004 All rights reserved.
00005 
00006 University of Oxford means the Chancellor, Masters and Scholars of the
00007 University of Oxford, having an administrative office at Wellington
00008 Square, Oxford OX1 2JD, UK.
00009 
00010 This file is part of Chaste.
00011 
00012 Redistribution and use in source and binary forms, with or without
00013 modification, are permitted provided that the following conditions are met:
00014  * Redistributions of source code must retain the above copyright notice,
00015    this list of conditions and the following disclaimer.
00016  * Redistributions in binary form must reproduce the above copyright notice,
00017    this list of conditions and the following disclaimer in the documentation
00018    and/or other materials provided with the distribution.
00019  * Neither the name of the University of Oxford nor the names of its
00020    contributors may be used to endorse or promote products derived from this
00021    software without specific prior written permission.
00022 
00023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00024 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00025 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00026 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
00027 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00028 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
00029 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00030 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00032 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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; // Circular definition (cells need to know about cycle models and vice-versa).
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         // These first four are also dealt with by {load,save}_construct_data
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     // Save data required to construct instance
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     // Retrieve data from archive required to construct new instance
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     // Invoke inplace constructor to initialize instance
00414     ::new(t)Cell(p_mutation_state, p_cell_cycle_model, archiving, cell_property_collection);
00415 }
00416 }
00417 } // namespace ...
00418 
00419 #endif /*CELL_HPP_*/

Generated by  doxygen 1.6.2