gen_count_term.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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_COUNT_TERM_H
  12. #define API_GEN_COUNT_TERM_H
  13. #include "api/api_common.h"
  14. #include "api/base_data_class.h"
  15. namespace MCell {
  16. namespace API {
  17. class Complex;
  18. class CountTerm;
  19. class ReactionRule;
  20. class Region;
  21. class PythonExportContext;
  22. #define COUNT_TERM_CTOR() \
  23. CountTerm( \
  24. std::shared_ptr<Complex> species_pattern_ = nullptr, \
  25. std::shared_ptr<Complex> molecules_pattern_ = nullptr, \
  26. std::shared_ptr<ReactionRule> reaction_rule_ = nullptr, \
  27. std::shared_ptr<Region> region_ = nullptr, \
  28. const ExprNodeType node_type_ = ExprNodeType::LEAF, \
  29. std::shared_ptr<CountTerm> left_node_ = nullptr, \
  30. std::shared_ptr<CountTerm> right_node_ = nullptr, \
  31. const uint64_t initial_reactions_count_ = 0 \
  32. ) { \
  33. class_name = "CountTerm"; \
  34. species_pattern = species_pattern_; \
  35. molecules_pattern = molecules_pattern_; \
  36. reaction_rule = reaction_rule_; \
  37. region = region_; \
  38. node_type = node_type_; \
  39. left_node = left_node_; \
  40. right_node = right_node_; \
  41. initial_reactions_count = initial_reactions_count_; \
  42. postprocess_in_ctor(); \
  43. check_semantics(); \
  44. } \
  45. CountTerm(DefaultCtorArgType) : \
  46. GenCountTerm(DefaultCtorArgType()) { \
  47. set_all_attributes_as_default_or_unset(); \
  48. set_all_custom_attributes_to_default(); \
  49. }
  50. class GenCountTerm: public BaseDataClass {
  51. public:
  52. GenCountTerm() {
  53. }
  54. GenCountTerm(DefaultCtorArgType) {
  55. }
  56. void postprocess_in_ctor() override {}
  57. void check_semantics() const override;
  58. void set_initialized() override;
  59. void set_all_attributes_as_default_or_unset() override;
  60. std::shared_ptr<CountTerm> copy_count_term() const;
  61. std::shared_ptr<CountTerm> deepcopy_count_term(py::dict = py::dict()) const;
  62. virtual bool __eq__(const CountTerm& other) const;
  63. virtual bool eq_nonarray_attributes(const CountTerm& other, const bool ignore_name = false) const;
  64. bool operator == (const CountTerm& other) const { return __eq__(other);}
  65. bool operator != (const CountTerm& other) const { return !__eq__(other);}
  66. std::string to_str(const bool all_details=false, const std::string ind="") const override;
  67. std::string export_to_python(std::ostream& out, PythonExportContext& ctx) override;
  68. // --- attributes ---
  69. std::shared_ptr<Complex> species_pattern;
  70. virtual void set_species_pattern(std::shared_ptr<Complex> new_species_pattern_) {
  71. if (initialized) {
  72. throw RuntimeError("Value 'species_pattern' of object with name " + name + " (class " + class_name + ") "
  73. "cannot be set after model was initialized.");
  74. }
  75. cached_data_are_uptodate = false;
  76. species_pattern = new_species_pattern_;
  77. }
  78. virtual std::shared_ptr<Complex> get_species_pattern() const {
  79. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  80. return species_pattern;
  81. }
  82. std::shared_ptr<Complex> molecules_pattern;
  83. virtual void set_molecules_pattern(std::shared_ptr<Complex> new_molecules_pattern_) {
  84. if (initialized) {
  85. throw RuntimeError("Value 'molecules_pattern' of object with name " + name + " (class " + class_name + ") "
  86. "cannot be set after model was initialized.");
  87. }
  88. cached_data_are_uptodate = false;
  89. molecules_pattern = new_molecules_pattern_;
  90. }
  91. virtual std::shared_ptr<Complex> get_molecules_pattern() const {
  92. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  93. return molecules_pattern;
  94. }
  95. std::shared_ptr<ReactionRule> reaction_rule;
  96. virtual void set_reaction_rule(std::shared_ptr<ReactionRule> new_reaction_rule_) {
  97. if (initialized) {
  98. throw RuntimeError("Value 'reaction_rule' of object with name " + name + " (class " + class_name + ") "
  99. "cannot be set after model was initialized.");
  100. }
  101. cached_data_are_uptodate = false;
  102. reaction_rule = new_reaction_rule_;
  103. }
  104. virtual std::shared_ptr<ReactionRule> get_reaction_rule() const {
  105. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  106. return reaction_rule;
  107. }
  108. std::shared_ptr<Region> region;
  109. virtual void set_region(std::shared_ptr<Region> new_region_) {
  110. if (initialized) {
  111. throw RuntimeError("Value 'region' of object with name " + name + " (class " + class_name + ") "
  112. "cannot be set after model was initialized.");
  113. }
  114. cached_data_are_uptodate = false;
  115. region = new_region_;
  116. }
  117. virtual std::shared_ptr<Region> get_region() const {
  118. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  119. return region;
  120. }
  121. ExprNodeType node_type;
  122. virtual void set_node_type(const ExprNodeType new_node_type_) {
  123. if (initialized) {
  124. throw RuntimeError("Value 'node_type' of object with name " + name + " (class " + class_name + ") "
  125. "cannot be set after model was initialized.");
  126. }
  127. cached_data_are_uptodate = false;
  128. node_type = new_node_type_;
  129. }
  130. virtual ExprNodeType get_node_type() const {
  131. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  132. return node_type;
  133. }
  134. std::shared_ptr<CountTerm> left_node;
  135. virtual void set_left_node(std::shared_ptr<CountTerm> new_left_node_) {
  136. if (initialized) {
  137. throw RuntimeError("Value 'left_node' of object with name " + name + " (class " + class_name + ") "
  138. "cannot be set after model was initialized.");
  139. }
  140. cached_data_are_uptodate = false;
  141. left_node = new_left_node_;
  142. }
  143. virtual std::shared_ptr<CountTerm> get_left_node() const {
  144. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  145. return left_node;
  146. }
  147. std::shared_ptr<CountTerm> right_node;
  148. virtual void set_right_node(std::shared_ptr<CountTerm> new_right_node_) {
  149. if (initialized) {
  150. throw RuntimeError("Value 'right_node' of object with name " + name + " (class " + class_name + ") "
  151. "cannot be set after model was initialized.");
  152. }
  153. cached_data_are_uptodate = false;
  154. right_node = new_right_node_;
  155. }
  156. virtual std::shared_ptr<CountTerm> get_right_node() const {
  157. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  158. return right_node;
  159. }
  160. uint64_t initial_reactions_count;
  161. virtual void set_initial_reactions_count(const uint64_t new_initial_reactions_count_) {
  162. if (initialized) {
  163. throw RuntimeError("Value 'initial_reactions_count' of object with name " + name + " (class " + class_name + ") "
  164. "cannot be set after model was initialized.");
  165. }
  166. cached_data_are_uptodate = false;
  167. initial_reactions_count = new_initial_reactions_count_;
  168. }
  169. virtual uint64_t get_initial_reactions_count() const {
  170. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  171. return initial_reactions_count;
  172. }
  173. // --- methods ---
  174. virtual std::shared_ptr<CountTerm> __add__(std::shared_ptr<CountTerm> op2) = 0;
  175. virtual std::shared_ptr<CountTerm> __sub__(std::shared_ptr<CountTerm> op2) = 0;
  176. }; // GenCountTerm
  177. class CountTerm;
  178. py::class_<CountTerm> define_pybinding_CountTerm(py::module& m);
  179. } // namespace API
  180. } // namespace MCell
  181. #endif // API_GEN_COUNT_TERM_H