gen_base_chkpt_mol.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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_BASE_CHKPT_MOL_H
  12. #define API_GEN_BASE_CHKPT_MOL_H
  13. #include "api/api_common.h"
  14. #include "api/base_data_class.h"
  15. namespace MCell {
  16. namespace API {
  17. class BaseChkptMol;
  18. class Species;
  19. class PythonExportContext;
  20. #define BASE_CHKPT_MOL_CTOR() \
  21. BaseChkptMol( \
  22. const int id_, \
  23. std::shared_ptr<Species> species_, \
  24. const double diffusion_time_, \
  25. const double birthday_, \
  26. const int flags_, \
  27. const double unimol_rxn_time_ = FLT_UNSET \
  28. ) { \
  29. class_name = "BaseChkptMol"; \
  30. id = id_; \
  31. species = species_; \
  32. diffusion_time = diffusion_time_; \
  33. birthday = birthday_; \
  34. flags = flags_; \
  35. unimol_rxn_time = unimol_rxn_time_; \
  36. postprocess_in_ctor(); \
  37. check_semantics(); \
  38. } \
  39. BaseChkptMol(DefaultCtorArgType) : \
  40. GenBaseChkptMol(DefaultCtorArgType()) { \
  41. set_all_attributes_as_default_or_unset(); \
  42. set_all_custom_attributes_to_default(); \
  43. }
  44. class GenBaseChkptMol: public BaseDataClass {
  45. public:
  46. GenBaseChkptMol() {
  47. }
  48. GenBaseChkptMol(DefaultCtorArgType) {
  49. }
  50. void postprocess_in_ctor() override {}
  51. void check_semantics() const override;
  52. void set_initialized() override;
  53. void set_all_attributes_as_default_or_unset() override;
  54. std::shared_ptr<BaseChkptMol> copy_base_chkpt_mol() const;
  55. std::shared_ptr<BaseChkptMol> deepcopy_base_chkpt_mol(py::dict = py::dict()) const;
  56. virtual bool __eq__(const BaseChkptMol& other) const;
  57. virtual bool eq_nonarray_attributes(const BaseChkptMol& other, const bool ignore_name = false) const;
  58. bool operator == (const BaseChkptMol& other) const { return __eq__(other);}
  59. bool operator != (const BaseChkptMol& other) const { return !__eq__(other);}
  60. std::string to_str(const bool all_details=false, const std::string ind="") const override;
  61. std::string export_to_python(std::ostream& out, PythonExportContext& ctx) override;
  62. // --- attributes ---
  63. int id;
  64. virtual void set_id(const int new_id_) {
  65. if (initialized) {
  66. throw RuntimeError("Value 'id' of object with name " + name + " (class " + class_name + ") "
  67. "cannot be set after model was initialized.");
  68. }
  69. cached_data_are_uptodate = false;
  70. id = new_id_;
  71. }
  72. virtual int get_id() const {
  73. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  74. return id;
  75. }
  76. std::shared_ptr<Species> species;
  77. virtual void set_species(std::shared_ptr<Species> new_species_) {
  78. if (initialized) {
  79. throw RuntimeError("Value 'species' of object with name " + name + " (class " + class_name + ") "
  80. "cannot be set after model was initialized.");
  81. }
  82. cached_data_are_uptodate = false;
  83. species = new_species_;
  84. }
  85. virtual std::shared_ptr<Species> get_species() const {
  86. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  87. return species;
  88. }
  89. double diffusion_time;
  90. virtual void set_diffusion_time(const double new_diffusion_time_) {
  91. if (initialized) {
  92. throw RuntimeError("Value 'diffusion_time' of object with name " + name + " (class " + class_name + ") "
  93. "cannot be set after model was initialized.");
  94. }
  95. cached_data_are_uptodate = false;
  96. diffusion_time = new_diffusion_time_;
  97. }
  98. virtual double get_diffusion_time() const {
  99. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  100. return diffusion_time;
  101. }
  102. double birthday;
  103. virtual void set_birthday(const double new_birthday_) {
  104. if (initialized) {
  105. throw RuntimeError("Value 'birthday' of object with name " + name + " (class " + class_name + ") "
  106. "cannot be set after model was initialized.");
  107. }
  108. cached_data_are_uptodate = false;
  109. birthday = new_birthday_;
  110. }
  111. virtual double get_birthday() const {
  112. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  113. return birthday;
  114. }
  115. int flags;
  116. virtual void set_flags(const int new_flags_) {
  117. if (initialized) {
  118. throw RuntimeError("Value 'flags' of object with name " + name + " (class " + class_name + ") "
  119. "cannot be set after model was initialized.");
  120. }
  121. cached_data_are_uptodate = false;
  122. flags = new_flags_;
  123. }
  124. virtual int get_flags() const {
  125. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  126. return flags;
  127. }
  128. double unimol_rxn_time;
  129. virtual void set_unimol_rxn_time(const double new_unimol_rxn_time_) {
  130. if (initialized) {
  131. throw RuntimeError("Value 'unimol_rxn_time' of object with name " + name + " (class " + class_name + ") "
  132. "cannot be set after model was initialized.");
  133. }
  134. cached_data_are_uptodate = false;
  135. unimol_rxn_time = new_unimol_rxn_time_;
  136. }
  137. virtual double get_unimol_rxn_time() const {
  138. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  139. return unimol_rxn_time;
  140. }
  141. // --- methods ---
  142. }; // GenBaseChkptMol
  143. class BaseChkptMol;
  144. py::class_<BaseChkptMol> define_pybinding_BaseChkptMol(py::module& m);
  145. } // namespace API
  146. } // namespace MCell
  147. #endif // API_GEN_BASE_CHKPT_MOL_H