gen_chkpt_vol_mol.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /******************************************************************************
  2. *
  3. * Copyright (C) 2021 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 API_GEN_CHKPT_VOL_MOL_H
  12. #define API_GEN_CHKPT_VOL_MOL_H
  13. #include "api/api_common.h"
  14. #include "api/base_chkpt_mol.h"
  15. namespace MCell {
  16. namespace API {
  17. class ChkptVolMol;
  18. class Species;
  19. class PythonExportContext;
  20. #define CHKPT_VOL_MOL_CTOR() \
  21. ChkptVolMol( \
  22. const Vec3& pos_, \
  23. const int id_, \
  24. std::shared_ptr<Species> species_, \
  25. const double diffusion_time_, \
  26. const double birthday_, \
  27. const int flags_, \
  28. const double unimol_rxn_time_ = FLT_UNSET \
  29. ) : GenChkptVolMol(id_,species_,diffusion_time_,birthday_,flags_,unimol_rxn_time_) { \
  30. class_name = "ChkptVolMol"; \
  31. pos = pos_; \
  32. id = id_; \
  33. species = species_; \
  34. diffusion_time = diffusion_time_; \
  35. birthday = birthday_; \
  36. flags = flags_; \
  37. unimol_rxn_time = unimol_rxn_time_; \
  38. postprocess_in_ctor(); \
  39. check_semantics(); \
  40. } \
  41. ChkptVolMol(DefaultCtorArgType) : \
  42. GenChkptVolMol(DefaultCtorArgType()) { \
  43. set_all_attributes_as_default_or_unset(); \
  44. set_all_custom_attributes_to_default(); \
  45. }
  46. class GenChkptVolMol: public BaseChkptMol {
  47. public:
  48. GenChkptVolMol(
  49. const int id_,
  50. std::shared_ptr<Species> species_,
  51. const double diffusion_time_,
  52. const double birthday_,
  53. const int flags_,
  54. const double unimol_rxn_time_ = FLT_UNSET
  55. ) : BaseChkptMol(id_,species_,diffusion_time_,birthday_,flags_,unimol_rxn_time_) {
  56. }
  57. GenChkptVolMol() : BaseChkptMol(DefaultCtorArgType()) {
  58. }
  59. GenChkptVolMol(DefaultCtorArgType) {
  60. }
  61. void postprocess_in_ctor() override {}
  62. void check_semantics() const override;
  63. void set_initialized() override;
  64. void set_all_attributes_as_default_or_unset() override;
  65. std::shared_ptr<ChkptVolMol> copy_chkpt_vol_mol() const;
  66. std::shared_ptr<ChkptVolMol> deepcopy_chkpt_vol_mol(py::dict = py::dict()) const;
  67. virtual bool __eq__(const ChkptVolMol& other) const;
  68. virtual bool eq_nonarray_attributes(const ChkptVolMol& other, const bool ignore_name = false) const;
  69. bool operator == (const ChkptVolMol& other) const { return __eq__(other);}
  70. bool operator != (const ChkptVolMol& other) const { return !__eq__(other);}
  71. std::string to_str(const bool all_details=false, const std::string ind="") const override;
  72. virtual std::string export_to_python(std::ostream& out, PythonExportContext& ctx);
  73. // --- attributes ---
  74. Vec3 pos;
  75. virtual void set_pos(const Vec3& new_pos_) {
  76. if (initialized) {
  77. throw RuntimeError("Value 'pos' of object with name " + name + " (class " + class_name + ") "
  78. "cannot be set after model was initialized.");
  79. }
  80. cached_data_are_uptodate = false;
  81. pos = new_pos_;
  82. }
  83. virtual const Vec3& get_pos() const {
  84. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  85. return pos;
  86. }
  87. // --- methods ---
  88. }; // GenChkptVolMol
  89. class ChkptVolMol;
  90. py::class_<ChkptVolMol> define_pybinding_ChkptVolMol(py::module& m);
  91. } // namespace API
  92. } // namespace MCell
  93. #endif // API_GEN_CHKPT_VOL_MOL_H