gen_surface_class.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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_CLASS_H
  12. #define API_GEN_SURFACE_CLASS_H
  13. #include "api/api_common.h"
  14. #include "api/surface_property.h"
  15. namespace MCell {
  16. namespace API {
  17. class SurfaceClass;
  18. class Complex;
  19. class SurfaceProperty;
  20. class PythonExportContext;
  21. #define SURFACE_CLASS_CTOR() \
  22. SurfaceClass( \
  23. const std::string& name_, \
  24. const std::vector<std::shared_ptr<SurfaceProperty>> properties_ = std::vector<std::shared_ptr<SurfaceProperty>>(), \
  25. const SurfacePropertyType type_ = SurfacePropertyType::UNSET, \
  26. std::shared_ptr<Complex> affected_complex_pattern_ = nullptr, \
  27. const double concentration_ = FLT_UNSET \
  28. ) : GenSurfaceClass(type_,affected_complex_pattern_,concentration_) { \
  29. class_name = "SurfaceClass"; \
  30. name = name_; \
  31. properties = properties_; \
  32. type = type_; \
  33. affected_complex_pattern = affected_complex_pattern_; \
  34. concentration = concentration_; \
  35. postprocess_in_ctor(); \
  36. check_semantics(); \
  37. } \
  38. SurfaceClass(DefaultCtorArgType) : \
  39. GenSurfaceClass(DefaultCtorArgType()) { \
  40. set_all_attributes_as_default_or_unset(); \
  41. set_all_custom_attributes_to_default(); \
  42. }
  43. class GenSurfaceClass: public SurfaceProperty {
  44. public:
  45. GenSurfaceClass(
  46. const SurfacePropertyType type_ = SurfacePropertyType::UNSET,
  47. std::shared_ptr<Complex> affected_complex_pattern_ = nullptr,
  48. const double concentration_ = FLT_UNSET
  49. ) : SurfaceProperty(type_,affected_complex_pattern_,concentration_) {
  50. }
  51. GenSurfaceClass(DefaultCtorArgType) {
  52. }
  53. void postprocess_in_ctor() override {}
  54. void check_semantics() const override;
  55. void set_initialized() override;
  56. void set_all_attributes_as_default_or_unset() override;
  57. std::shared_ptr<SurfaceClass> copy_surface_class() const;
  58. std::shared_ptr<SurfaceClass> deepcopy_surface_class(py::dict = py::dict()) const;
  59. virtual bool __eq__(const SurfaceClass& other) const;
  60. virtual bool eq_nonarray_attributes(const SurfaceClass& other, const bool ignore_name = false) const;
  61. bool operator == (const SurfaceClass& other) const { return __eq__(other);}
  62. bool operator != (const SurfaceClass& other) const { return !__eq__(other);}
  63. std::string to_str(const bool all_details=false, const std::string ind="") const override;
  64. virtual std::string export_to_python(std::ostream& out, PythonExportContext& ctx);
  65. virtual std::string export_vec_properties(std::ostream& out, PythonExportContext& ctx, const std::string& parent_name);
  66. // --- attributes ---
  67. std::vector<std::shared_ptr<SurfaceProperty>> properties;
  68. virtual void set_properties(const std::vector<std::shared_ptr<SurfaceProperty>> new_properties_) {
  69. if (initialized) {
  70. throw RuntimeError("Value 'properties' of object with name " + name + " (class " + class_name + ") "
  71. "cannot be set after model was initialized.");
  72. }
  73. cached_data_are_uptodate = false;
  74. properties = new_properties_;
  75. }
  76. virtual std::vector<std::shared_ptr<SurfaceProperty>>& get_properties() {
  77. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  78. return properties;
  79. }
  80. // --- methods ---
  81. }; // GenSurfaceClass
  82. class SurfaceClass;
  83. py::class_<SurfaceClass> define_pybinding_SurfaceClass(py::module& m);
  84. } // namespace API
  85. } // namespace MCell
  86. #endif // API_GEN_SURFACE_CLASS_H