gen_surface_property.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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_SURFACE_PROPERTY_H
  12. #define API_GEN_SURFACE_PROPERTY_H
  13. #include "api/api_common.h"
  14. #include "api/base_data_class.h"
  15. namespace MCell {
  16. namespace API {
  17. class SurfaceProperty;
  18. class Complex;
  19. class PythonExportContext;
  20. #define SURFACE_PROPERTY_CTOR() \
  21. SurfaceProperty( \
  22. const SurfacePropertyType type_ = SurfacePropertyType::UNSET, \
  23. std::shared_ptr<Complex> affected_complex_pattern_ = nullptr, \
  24. const double concentration_ = FLT_UNSET \
  25. ) { \
  26. class_name = "SurfaceProperty"; \
  27. type = type_; \
  28. affected_complex_pattern = affected_complex_pattern_; \
  29. concentration = concentration_; \
  30. postprocess_in_ctor(); \
  31. check_semantics(); \
  32. } \
  33. SurfaceProperty(DefaultCtorArgType) : \
  34. GenSurfaceProperty(DefaultCtorArgType()) { \
  35. set_all_attributes_as_default_or_unset(); \
  36. set_all_custom_attributes_to_default(); \
  37. }
  38. class GenSurfaceProperty: public BaseDataClass {
  39. public:
  40. GenSurfaceProperty() {
  41. }
  42. GenSurfaceProperty(DefaultCtorArgType) {
  43. }
  44. void postprocess_in_ctor() override {}
  45. void check_semantics() const override;
  46. void set_initialized() override;
  47. void set_all_attributes_as_default_or_unset() override;
  48. std::shared_ptr<SurfaceProperty> copy_surface_property() const;
  49. std::shared_ptr<SurfaceProperty> deepcopy_surface_property(py::dict = py::dict()) const;
  50. virtual bool __eq__(const SurfaceProperty& other) const;
  51. virtual bool eq_nonarray_attributes(const SurfaceProperty& other, const bool ignore_name = false) const;
  52. bool operator == (const SurfaceProperty& other) const { return __eq__(other);}
  53. bool operator != (const SurfaceProperty& other) const { return !__eq__(other);}
  54. std::string to_str(const bool all_details=false, const std::string ind="") const override;
  55. std::string export_to_python(std::ostream& out, PythonExportContext& ctx) override;
  56. // --- attributes ---
  57. SurfacePropertyType type;
  58. virtual void set_type(const SurfacePropertyType new_type_) {
  59. if (initialized) {
  60. throw RuntimeError("Value 'type' of object with name " + name + " (class " + class_name + ") "
  61. "cannot be set after model was initialized.");
  62. }
  63. cached_data_are_uptodate = false;
  64. type = new_type_;
  65. }
  66. virtual SurfacePropertyType get_type() const {
  67. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  68. return type;
  69. }
  70. std::shared_ptr<Complex> affected_complex_pattern;
  71. virtual void set_affected_complex_pattern(std::shared_ptr<Complex> new_affected_complex_pattern_) {
  72. if (initialized) {
  73. throw RuntimeError("Value 'affected_complex_pattern' of object with name " + name + " (class " + class_name + ") "
  74. "cannot be set after model was initialized.");
  75. }
  76. cached_data_are_uptodate = false;
  77. affected_complex_pattern = new_affected_complex_pattern_;
  78. }
  79. virtual std::shared_ptr<Complex> get_affected_complex_pattern() const {
  80. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  81. return affected_complex_pattern;
  82. }
  83. double concentration;
  84. virtual void set_concentration(const double new_concentration_) {
  85. if (initialized) {
  86. throw RuntimeError("Value 'concentration' of object with name " + name + " (class " + class_name + ") "
  87. "cannot be set after model was initialized.");
  88. }
  89. cached_data_are_uptodate = false;
  90. concentration = new_concentration_;
  91. }
  92. virtual double get_concentration() const {
  93. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  94. return concentration;
  95. }
  96. // --- methods ---
  97. }; // GenSurfaceProperty
  98. class SurfaceProperty;
  99. py::class_<SurfaceProperty> define_pybinding_SurfaceProperty(py::module& m);
  100. } // namespace API
  101. } // namespace MCell
  102. #endif // API_GEN_SURFACE_PROPERTY_H