gen_release_pattern.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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_PATTERN_H
  12. #define API_GEN_RELEASE_PATTERN_H
  13. #include "api/api_common.h"
  14. #include "api/base_data_class.h"
  15. namespace MCell {
  16. namespace API {
  17. class ReleasePattern;
  18. class PythonExportContext;
  19. #define RELEASE_PATTERN_CTOR() \
  20. ReleasePattern( \
  21. const std::string& name_ = STR_UNSET, \
  22. const double release_interval_ = TIME_INFINITY, \
  23. const double train_duration_ = TIME_INFINITY, \
  24. const double train_interval_ = TIME_INFINITY, \
  25. const int number_of_trains_ = 1 \
  26. ) { \
  27. class_name = "ReleasePattern"; \
  28. name = name_; \
  29. release_interval = release_interval_; \
  30. train_duration = train_duration_; \
  31. train_interval = train_interval_; \
  32. number_of_trains = number_of_trains_; \
  33. postprocess_in_ctor(); \
  34. check_semantics(); \
  35. } \
  36. ReleasePattern(DefaultCtorArgType) : \
  37. GenReleasePattern(DefaultCtorArgType()) { \
  38. set_all_attributes_as_default_or_unset(); \
  39. set_all_custom_attributes_to_default(); \
  40. }
  41. class GenReleasePattern: public BaseDataClass {
  42. public:
  43. GenReleasePattern() {
  44. }
  45. GenReleasePattern(DefaultCtorArgType) {
  46. }
  47. void postprocess_in_ctor() override {}
  48. void check_semantics() const override;
  49. void set_initialized() override;
  50. void set_all_attributes_as_default_or_unset() override;
  51. std::shared_ptr<ReleasePattern> copy_release_pattern() const;
  52. std::shared_ptr<ReleasePattern> deepcopy_release_pattern(py::dict = py::dict()) const;
  53. virtual bool __eq__(const ReleasePattern& other) const;
  54. virtual bool eq_nonarray_attributes(const ReleasePattern& other, const bool ignore_name = false) const;
  55. bool operator == (const ReleasePattern& other) const { return __eq__(other);}
  56. bool operator != (const ReleasePattern& other) const { return !__eq__(other);}
  57. std::string to_str(const bool all_details=false, const std::string ind="") const override;
  58. std::string export_to_python(std::ostream& out, PythonExportContext& ctx) override;
  59. // --- attributes ---
  60. double release_interval;
  61. virtual void set_release_interval(const double new_release_interval_) {
  62. if (initialized) {
  63. throw RuntimeError("Value 'release_interval' of object with name " + name + " (class " + class_name + ") "
  64. "cannot be set after model was initialized.");
  65. }
  66. cached_data_are_uptodate = false;
  67. release_interval = new_release_interval_;
  68. }
  69. virtual double get_release_interval() const {
  70. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  71. return release_interval;
  72. }
  73. double train_duration;
  74. virtual void set_train_duration(const double new_train_duration_) {
  75. if (initialized) {
  76. throw RuntimeError("Value 'train_duration' of object with name " + name + " (class " + class_name + ") "
  77. "cannot be set after model was initialized.");
  78. }
  79. cached_data_are_uptodate = false;
  80. train_duration = new_train_duration_;
  81. }
  82. virtual double get_train_duration() const {
  83. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  84. return train_duration;
  85. }
  86. double train_interval;
  87. virtual void set_train_interval(const double new_train_interval_) {
  88. if (initialized) {
  89. throw RuntimeError("Value 'train_interval' of object with name " + name + " (class " + class_name + ") "
  90. "cannot be set after model was initialized.");
  91. }
  92. cached_data_are_uptodate = false;
  93. train_interval = new_train_interval_;
  94. }
  95. virtual double get_train_interval() const {
  96. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  97. return train_interval;
  98. }
  99. int number_of_trains;
  100. virtual void set_number_of_trains(const int new_number_of_trains_) {
  101. if (initialized) {
  102. throw RuntimeError("Value 'number_of_trains' of object with name " + name + " (class " + class_name + ") "
  103. "cannot be set after model was initialized.");
  104. }
  105. cached_data_are_uptodate = false;
  106. number_of_trains = new_number_of_trains_;
  107. }
  108. virtual int get_number_of_trains() const {
  109. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  110. return number_of_trains;
  111. }
  112. // --- methods ---
  113. }; // GenReleasePattern
  114. class ReleasePattern;
  115. py::class_<ReleasePattern> define_pybinding_ReleasePattern(py::module& m);
  116. } // namespace API
  117. } // namespace MCell
  118. #endif // API_GEN_RELEASE_PATTERN_H