gen_chkpt_surf_mol.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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_SURF_MOL_H
  12. #define API_GEN_CHKPT_SURF_MOL_H
  13. #include "api/api_common.h"
  14. #include "api/base_chkpt_mol.h"
  15. namespace MCell {
  16. namespace API {
  17. class ChkptSurfMol;
  18. class GeometryObject;
  19. class Species;
  20. class PythonExportContext;
  21. #define CHKPT_SURF_MOL_CTOR() \
  22. ChkptSurfMol( \
  23. const Vec2& pos_, \
  24. const Orientation orientation_, \
  25. std::shared_ptr<GeometryObject> geometry_object_, \
  26. const int wall_index_, \
  27. const int grid_tile_index_, \
  28. const int id_, \
  29. std::shared_ptr<Species> species_, \
  30. const double diffusion_time_, \
  31. const double birthday_, \
  32. const int flags_, \
  33. const double unimol_rxn_time_ = FLT_UNSET \
  34. ) : GenChkptSurfMol(id_,species_,diffusion_time_,birthday_,flags_,unimol_rxn_time_) { \
  35. class_name = "ChkptSurfMol"; \
  36. pos = pos_; \
  37. orientation = orientation_; \
  38. geometry_object = geometry_object_; \
  39. wall_index = wall_index_; \
  40. grid_tile_index = grid_tile_index_; \
  41. id = id_; \
  42. species = species_; \
  43. diffusion_time = diffusion_time_; \
  44. birthday = birthday_; \
  45. flags = flags_; \
  46. unimol_rxn_time = unimol_rxn_time_; \
  47. postprocess_in_ctor(); \
  48. check_semantics(); \
  49. } \
  50. ChkptSurfMol(DefaultCtorArgType) : \
  51. GenChkptSurfMol(DefaultCtorArgType()) { \
  52. set_all_attributes_as_default_or_unset(); \
  53. set_all_custom_attributes_to_default(); \
  54. }
  55. class GenChkptSurfMol: public BaseChkptMol {
  56. public:
  57. GenChkptSurfMol(
  58. const int id_,
  59. std::shared_ptr<Species> species_,
  60. const double diffusion_time_,
  61. const double birthday_,
  62. const int flags_,
  63. const double unimol_rxn_time_ = FLT_UNSET
  64. ) : BaseChkptMol(id_,species_,diffusion_time_,birthday_,flags_,unimol_rxn_time_) {
  65. }
  66. GenChkptSurfMol() : BaseChkptMol(DefaultCtorArgType()) {
  67. }
  68. GenChkptSurfMol(DefaultCtorArgType) {
  69. }
  70. void postprocess_in_ctor() override {}
  71. void check_semantics() const override;
  72. void set_initialized() override;
  73. void set_all_attributes_as_default_or_unset() override;
  74. std::shared_ptr<ChkptSurfMol> copy_chkpt_surf_mol() const;
  75. std::shared_ptr<ChkptSurfMol> deepcopy_chkpt_surf_mol(py::dict = py::dict()) const;
  76. virtual bool __eq__(const ChkptSurfMol& other) const;
  77. virtual bool eq_nonarray_attributes(const ChkptSurfMol& other, const bool ignore_name = false) const;
  78. bool operator == (const ChkptSurfMol& other) const { return __eq__(other);}
  79. bool operator != (const ChkptSurfMol& other) const { return !__eq__(other);}
  80. std::string to_str(const bool all_details=false, const std::string ind="") const override;
  81. virtual std::string export_to_python(std::ostream& out, PythonExportContext& ctx);
  82. // --- attributes ---
  83. Vec2 pos;
  84. virtual void set_pos(const Vec2& new_pos_) {
  85. if (initialized) {
  86. throw RuntimeError("Value 'pos' of object with name " + name + " (class " + class_name + ") "
  87. "cannot be set after model was initialized.");
  88. }
  89. cached_data_are_uptodate = false;
  90. pos = new_pos_;
  91. }
  92. virtual const Vec2& get_pos() const {
  93. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  94. return pos;
  95. }
  96. Orientation orientation;
  97. virtual void set_orientation(const Orientation new_orientation_) {
  98. if (initialized) {
  99. throw RuntimeError("Value 'orientation' of object with name " + name + " (class " + class_name + ") "
  100. "cannot be set after model was initialized.");
  101. }
  102. cached_data_are_uptodate = false;
  103. orientation = new_orientation_;
  104. }
  105. virtual Orientation get_orientation() const {
  106. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  107. return orientation;
  108. }
  109. std::shared_ptr<GeometryObject> geometry_object;
  110. virtual void set_geometry_object(std::shared_ptr<GeometryObject> new_geometry_object_) {
  111. if (initialized) {
  112. throw RuntimeError("Value 'geometry_object' of object with name " + name + " (class " + class_name + ") "
  113. "cannot be set after model was initialized.");
  114. }
  115. cached_data_are_uptodate = false;
  116. geometry_object = new_geometry_object_;
  117. }
  118. virtual std::shared_ptr<GeometryObject> get_geometry_object() const {
  119. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  120. return geometry_object;
  121. }
  122. int wall_index;
  123. virtual void set_wall_index(const int new_wall_index_) {
  124. if (initialized) {
  125. throw RuntimeError("Value 'wall_index' of object with name " + name + " (class " + class_name + ") "
  126. "cannot be set after model was initialized.");
  127. }
  128. cached_data_are_uptodate = false;
  129. wall_index = new_wall_index_;
  130. }
  131. virtual int get_wall_index() const {
  132. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  133. return wall_index;
  134. }
  135. int grid_tile_index;
  136. virtual void set_grid_tile_index(const int new_grid_tile_index_) {
  137. if (initialized) {
  138. throw RuntimeError("Value 'grid_tile_index' of object with name " + name + " (class " + class_name + ") "
  139. "cannot be set after model was initialized.");
  140. }
  141. cached_data_are_uptodate = false;
  142. grid_tile_index = new_grid_tile_index_;
  143. }
  144. virtual int get_grid_tile_index() const {
  145. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  146. return grid_tile_index;
  147. }
  148. // --- methods ---
  149. }; // GenChkptSurfMol
  150. class ChkptSurfMol;
  151. py::class_<ChkptSurfMol> define_pybinding_ChkptSurfMol(py::module& m);
  152. } // namespace API
  153. } // namespace MCell
  154. #endif // API_GEN_CHKPT_SURF_MOL_H