text: /*
  
  Copyright (c) 2005-2020, University of Oxford.
  All rights reserved.
  
  University of Oxford means the Chancellor, Masters and Scholars of the
  University of Oxford, having an administrative office at Wellington
  Square, Oxford OX1 2JD, UK.
  
  This file is part of Chaste.
  
  Redistribution and use in source and binary forms, with or without
  modification, are permitted provided that the following conditions are met:
   * Redistributions of source code must retain the above copyright notice,
     this list of conditions and the following disclaimer.
   * Redistributions in binary form must reproduce the above copyright notice,
     this list of conditions and the following disclaimer in the documentation
     and/or other materials provided with the distribution.
   * Neither the name of the University of Oxford nor the names of its
     contributors may be used to endorse or promote products derived from this
     software without specific prior written permission.
  
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
  */
  
  #ifndef WNTCELLCYCLEMODEL_HPP_
  #define WNTCELLCYCLEMODEL_HPP_
  
  #include "ChasteSerialization.hpp"
  #include <boost/serialization/base_object.hpp>
  
  #include <cfloat>
  
  #include "AbstractWntOdeBasedCellCycleModel.hpp"
  #include "WntCellCycleOdeSystem.hpp"
  #include "AbstractCellMutationState.hpp"
  
  /**
   * Wnt-dependent cell-cycle model. Needs to operate with a WntConcentration
   * singleton object.
   *
   * This model has a constant length M phase, runs ODEs to decide when
   * to finish G1 phase then adds time for S and G2 phases. The CellProliferativeType is
   * updated dependent on the concentration of beta-catenin (given by one
   * of the ODEs).
   *
   * Note that this class uses C++'s default copying semantics, and so
   * doesn't implement a copy constructor or operator=.
   */
  class WntCellCycleModel : public AbstractWntOdeBasedCellCycleModel
  {
  private:
      /** Needed for serialization. */
      friend class boost::serialization::access;
      /**
       * Archive the cell-cycle model and ODE system.
       *
       * @param archive the archive
       * @param version the archive version
       */
      template<class Archive>
      void serialize(Archive & archive, const unsigned int version)
      {
          archive & boost::serialization::base_object<AbstractWntOdeBasedCellCycleModel>(*this);
      }
  
      /**
       * Update the cell type according to the current beta catenin
       * level as given by the WntCellCycleOdeSystem.
       *
       * This method carries out the work for UpdateCellProliferativeType(), but
       * does not check the current time, so can also be called by
       * Initialise().
       */
      void ChangeCellProliferativeTypeDueToCurrentBetaCateninLevel();
  
      /**
       * Adjust any ODE parameters needed before solving until currentTime.
       *
       * @param currentTime  the time up to which the system will be solved.
       */
      void AdjustOdeParameters(double currentTime);
  
  protected:
  
      /**
       * Protected copy-constructor for use by CreateCellCycleModel.
       * The only way for external code to create a copy of a cell cycle model
       * is by calling that method, to ensure that a model of the correct subclass is created.
       * This copy-constructor helps subclasses to ensure that all member variables are correctly copied when this happens.
       *
       * This method is called by child classes to set member variables for a daughter cell upon cell division.
       * Note that the parent cell cycle model will have had ResetForDivision() called just before CreateCellCycleModel() is called,
       * so performing an exact copy of the parent is suitable behaviour. Any daughter-cell-specific initialisation
       * can be done in InitialiseDaughterCell().
       *
       * @param rModel the cell cycle model to copy.
       */
      WntCellCycleModel(const WntCellCycleModel& rModel);
  
  public:
  
      /**
       * Default constructor.
       *
       * @param pOdeSolver An optional pointer to a cell-cycle model ODE solver object (allows the use of different ODE solvers)
       */
      WntCellCycleModel(boost::shared_ptr<AbstractCellCycleModelOdeSolver> pOdeSolver = boost::shared_ptr<AbstractCellCycleModelOdeSolver>());
  
      /** Empty virtual destructor so archiving works with static libraries. */
      ~WntCellCycleModel();
  
      /**
       * Overridden builder method to create new copies of
       * this cell-cycle model.
       * @return the new cell-cycle model
       */
      AbstractCellCycleModel* CreateCellCycleModel();
  
      /**
       * Initialise the cell-cycle model at the start of a simulation.
       *
       * This overridden method sets up a new WntCellCycleOdeSystem
       * and sets the cell type according to the current beta catenin
       * level.
       */
      void Initialise();
  
      /**
       * Overridden OutputCellCycleModelParameters() method.
       *
       * @param rParamsFile the file stream to which the parameters are output
       */
      virtual void OutputCellCycleModelParameters(out_stream& rParamsFile);
  };
  
  // Declare identifier for the serializer
  #include "SerializationExportWrapper.hpp"
  CHASTE_CLASS_EXPORT(WntCellCycleModel)
  #include "CellCycleModelOdeSolverExportWrapper.hpp"
  EXPORT_CELL_CYCLE_MODEL_ODE_SOLVER(WntCellCycleModel)
  
  #endif /*WNTCELLCYCLEMODEL_HPP_*/
  