base_chkpt_mol.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /******************************************************************************
  2. *
  3. * Copyright (C) 2020 by
  4. * The Salk Institute for Biological Studies
  5. *
  6. * Use of this source code is governed by an MIT-style
  7. * license that can be found in the LICENSE file or at
  8. * https://opensource.org/licenses/MIT.
  9. *
  10. ******************************************************************************/
  11. #ifndef LIBMCELL_API_BASE_CHKPT_MOL_H
  12. #define LIBMCELL_API_BASE_CHKPT_MOL_H
  13. #include "generated/gen_base_chkpt_mol.h"
  14. #include "api/api_common.h"
  15. namespace MCell {
  16. class Molecule;
  17. namespace API {
  18. // macro for GenChpt*Mol construction, used in Chpt*Mol constructors
  19. #define GEN_CHKPT_MOL_CTOR(GEN_CLASS_NAME, M, ID_SPECIES_MAP, TIME_UNIT) \
  20. GEN_CLASS_NAME(\
  21. M.id, \
  22. ID_SPECIES_MAP.find(M.species_id)->second, \
  23. M.diffusion_time * TIME_UNIT, \
  24. M.birthday * TIME_UNIT, \
  25. M.flags, \
  26. ((M.unimol_rxn_time != TIME_INVALID) ? M.unimol_rxn_time * TIME_UNIT : FLT_UNSET) \
  27. )
  28. class BaseChkptMol: public GenBaseChkptMol {
  29. public:
  30. BASE_CHKPT_MOL_CTOR()
  31. BaseChkptMol() {
  32. }
  33. void postprocess_in_ctor() override {
  34. set_all_custom_attributes_to_default();
  35. }
  36. void set_all_custom_attributes_to_default() override {
  37. type = MoleculeType::UNSET;
  38. }
  39. bool export_as_string_without_newlines() const override {
  40. return true;
  41. }
  42. bool export_even_if_already_exported() const override {
  43. return true;
  44. }
  45. // used when casting to a derived class
  46. MoleculeType type;
  47. };
  48. } // namespace API
  49. } // namespace MCell
  50. #endif // LIBMCELL_API_BASE_CHKPT_MOL_H