gen_release_site.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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_RELEASE_SITE_H
  12. #define API_GEN_RELEASE_SITE_H
  13. #include "api/api_common.h"
  14. #include "api/base_data_class.h"
  15. namespace MCell {
  16. namespace API {
  17. class ReleaseSite;
  18. class Complex;
  19. class MoleculeReleaseInfo;
  20. class Region;
  21. class ReleasePattern;
  22. class PythonExportContext;
  23. #define RELEASE_SITE_CTOR() \
  24. ReleaseSite( \
  25. const std::string& name_, \
  26. std::shared_ptr<Complex> complex_ = nullptr, \
  27. const std::vector<std::shared_ptr<MoleculeReleaseInfo>> molecule_list_ = std::vector<std::shared_ptr<MoleculeReleaseInfo>>(), \
  28. const double release_time_ = 0, \
  29. std::shared_ptr<ReleasePattern> release_pattern_ = nullptr, \
  30. const Shape shape_ = Shape::UNSET, \
  31. std::shared_ptr<Region> region_ = nullptr, \
  32. const std::vector<double> location_ = std::vector<double>(), \
  33. const double site_diameter_ = 0, \
  34. const double site_radius_ = FLT_UNSET, \
  35. const double number_to_release_ = FLT_UNSET, \
  36. const double density_ = FLT_UNSET, \
  37. const double concentration_ = FLT_UNSET, \
  38. const double release_probability_ = 1 \
  39. ) { \
  40. class_name = "ReleaseSite"; \
  41. name = name_; \
  42. complex = complex_; \
  43. molecule_list = molecule_list_; \
  44. release_time = release_time_; \
  45. release_pattern = release_pattern_; \
  46. shape = shape_; \
  47. region = region_; \
  48. location = location_; \
  49. site_diameter = site_diameter_; \
  50. site_radius = site_radius_; \
  51. number_to_release = number_to_release_; \
  52. density = density_; \
  53. concentration = concentration_; \
  54. release_probability = release_probability_; \
  55. postprocess_in_ctor(); \
  56. check_semantics(); \
  57. } \
  58. ReleaseSite(DefaultCtorArgType) : \
  59. GenReleaseSite(DefaultCtorArgType()) { \
  60. set_all_attributes_as_default_or_unset(); \
  61. set_all_custom_attributes_to_default(); \
  62. }
  63. class GenReleaseSite: public BaseDataClass {
  64. public:
  65. GenReleaseSite() {
  66. }
  67. GenReleaseSite(DefaultCtorArgType) {
  68. }
  69. void postprocess_in_ctor() override {}
  70. void check_semantics() const override;
  71. void set_initialized() override;
  72. void set_all_attributes_as_default_or_unset() override;
  73. std::shared_ptr<ReleaseSite> copy_release_site() const;
  74. std::shared_ptr<ReleaseSite> deepcopy_release_site(py::dict = py::dict()) const;
  75. virtual bool __eq__(const ReleaseSite& other) const;
  76. virtual bool eq_nonarray_attributes(const ReleaseSite& other, const bool ignore_name = false) const;
  77. bool operator == (const ReleaseSite& other) const { return __eq__(other);}
  78. bool operator != (const ReleaseSite& other) const { return !__eq__(other);}
  79. std::string to_str(const bool all_details=false, const std::string ind="") const override;
  80. std::string export_to_python(std::ostream& out, PythonExportContext& ctx) override;
  81. virtual std::string export_vec_molecule_list(std::ostream& out, PythonExportContext& ctx, const std::string& parent_name);
  82. virtual std::string export_vec_location(std::ostream& out, PythonExportContext& ctx, const std::string& parent_name);
  83. // --- attributes ---
  84. std::shared_ptr<Complex> complex;
  85. virtual void set_complex(std::shared_ptr<Complex> new_complex_) {
  86. if (initialized) {
  87. throw RuntimeError("Value 'complex' of object with name " + name + " (class " + class_name + ") "
  88. "cannot be set after model was initialized.");
  89. }
  90. cached_data_are_uptodate = false;
  91. complex = new_complex_;
  92. }
  93. virtual std::shared_ptr<Complex> get_complex() const {
  94. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  95. return complex;
  96. }
  97. std::vector<std::shared_ptr<MoleculeReleaseInfo>> molecule_list;
  98. virtual void set_molecule_list(const std::vector<std::shared_ptr<MoleculeReleaseInfo>> new_molecule_list_) {
  99. if (initialized) {
  100. throw RuntimeError("Value 'molecule_list' of object with name " + name + " (class " + class_name + ") "
  101. "cannot be set after model was initialized.");
  102. }
  103. cached_data_are_uptodate = false;
  104. molecule_list = new_molecule_list_;
  105. }
  106. virtual std::vector<std::shared_ptr<MoleculeReleaseInfo>>& get_molecule_list() {
  107. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  108. return molecule_list;
  109. }
  110. double release_time;
  111. virtual void set_release_time(const double new_release_time_) {
  112. if (initialized) {
  113. throw RuntimeError("Value 'release_time' of object with name " + name + " (class " + class_name + ") "
  114. "cannot be set after model was initialized.");
  115. }
  116. cached_data_are_uptodate = false;
  117. release_time = new_release_time_;
  118. }
  119. virtual double get_release_time() const {
  120. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  121. return release_time;
  122. }
  123. std::shared_ptr<ReleasePattern> release_pattern;
  124. virtual void set_release_pattern(std::shared_ptr<ReleasePattern> new_release_pattern_) {
  125. if (initialized) {
  126. throw RuntimeError("Value 'release_pattern' of object with name " + name + " (class " + class_name + ") "
  127. "cannot be set after model was initialized.");
  128. }
  129. cached_data_are_uptodate = false;
  130. release_pattern = new_release_pattern_;
  131. }
  132. virtual std::shared_ptr<ReleasePattern> get_release_pattern() const {
  133. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  134. return release_pattern;
  135. }
  136. Shape shape;
  137. virtual void set_shape(const Shape new_shape_) {
  138. if (initialized) {
  139. throw RuntimeError("Value 'shape' of object with name " + name + " (class " + class_name + ") "
  140. "cannot be set after model was initialized.");
  141. }
  142. cached_data_are_uptodate = false;
  143. shape = new_shape_;
  144. }
  145. virtual Shape get_shape() const {
  146. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  147. return shape;
  148. }
  149. std::shared_ptr<Region> region;
  150. virtual void set_region(std::shared_ptr<Region> new_region_) {
  151. if (initialized) {
  152. throw RuntimeError("Value 'region' of object with name " + name + " (class " + class_name + ") "
  153. "cannot be set after model was initialized.");
  154. }
  155. cached_data_are_uptodate = false;
  156. region = new_region_;
  157. }
  158. virtual std::shared_ptr<Region> get_region() const {
  159. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  160. return region;
  161. }
  162. std::vector<double> location;
  163. virtual void set_location(const std::vector<double> new_location_) {
  164. if (initialized) {
  165. throw RuntimeError("Value 'location' of object with name " + name + " (class " + class_name + ") "
  166. "cannot be set after model was initialized.");
  167. }
  168. cached_data_are_uptodate = false;
  169. location = new_location_;
  170. }
  171. virtual std::vector<double>& get_location() {
  172. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  173. return location;
  174. }
  175. double site_diameter;
  176. virtual void set_site_diameter(const double new_site_diameter_) {
  177. if (initialized) {
  178. throw RuntimeError("Value 'site_diameter' of object with name " + name + " (class " + class_name + ") "
  179. "cannot be set after model was initialized.");
  180. }
  181. cached_data_are_uptodate = false;
  182. site_diameter = new_site_diameter_;
  183. }
  184. virtual double get_site_diameter() const {
  185. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  186. return site_diameter;
  187. }
  188. double site_radius;
  189. virtual void set_site_radius(const double new_site_radius_) {
  190. if (initialized) {
  191. throw RuntimeError("Value 'site_radius' of object with name " + name + " (class " + class_name + ") "
  192. "cannot be set after model was initialized.");
  193. }
  194. cached_data_are_uptodate = false;
  195. site_radius = new_site_radius_;
  196. }
  197. virtual double get_site_radius() const {
  198. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  199. return site_radius;
  200. }
  201. double number_to_release;
  202. virtual void set_number_to_release(const double new_number_to_release_) {
  203. if (initialized) {
  204. throw RuntimeError("Value 'number_to_release' of object with name " + name + " (class " + class_name + ") "
  205. "cannot be set after model was initialized.");
  206. }
  207. cached_data_are_uptodate = false;
  208. number_to_release = new_number_to_release_;
  209. }
  210. virtual double get_number_to_release() const {
  211. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  212. return number_to_release;
  213. }
  214. double density;
  215. virtual void set_density(const double new_density_) {
  216. if (initialized) {
  217. throw RuntimeError("Value 'density' of object with name " + name + " (class " + class_name + ") "
  218. "cannot be set after model was initialized.");
  219. }
  220. cached_data_are_uptodate = false;
  221. density = new_density_;
  222. }
  223. virtual double get_density() const {
  224. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  225. return density;
  226. }
  227. double concentration;
  228. virtual void set_concentration(const double new_concentration_) {
  229. if (initialized) {
  230. throw RuntimeError("Value 'concentration' of object with name " + name + " (class " + class_name + ") "
  231. "cannot be set after model was initialized.");
  232. }
  233. cached_data_are_uptodate = false;
  234. concentration = new_concentration_;
  235. }
  236. virtual double get_concentration() const {
  237. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  238. return concentration;
  239. }
  240. double release_probability;
  241. virtual void set_release_probability(const double new_release_probability_) {
  242. if (initialized) {
  243. throw RuntimeError("Value 'release_probability' of object with name " + name + " (class " + class_name + ") "
  244. "cannot be set after model was initialized.");
  245. }
  246. cached_data_are_uptodate = false;
  247. release_probability = new_release_probability_;
  248. }
  249. virtual double get_release_probability() const {
  250. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  251. return release_probability;
  252. }
  253. // --- methods ---
  254. }; // GenReleaseSite
  255. class ReleaseSite;
  256. py::class_<ReleaseSite> define_pybinding_ReleaseSite(py::module& m);
  257. } // namespace API
  258. } // namespace MCell
  259. #endif // API_GEN_RELEASE_SITE_H