gen_complex.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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_COMPLEX_H
  12. #define API_GEN_COMPLEX_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 ElementaryMolecule;
  19. class Species;
  20. class PythonExportContext;
  21. #define COMPLEX_CTOR() \
  22. Complex( \
  23. const std::string& name_ = STR_UNSET, \
  24. const std::vector<std::shared_ptr<ElementaryMolecule>> elementary_molecules_ = std::vector<std::shared_ptr<ElementaryMolecule>>(), \
  25. const Orientation orientation_ = Orientation::DEFAULT, \
  26. const std::string& compartment_name_ = STR_UNSET \
  27. ) { \
  28. class_name = "Complex"; \
  29. name = name_; \
  30. elementary_molecules = elementary_molecules_; \
  31. orientation = orientation_; \
  32. compartment_name = compartment_name_; \
  33. postprocess_in_ctor(); \
  34. check_semantics(); \
  35. } \
  36. Complex(DefaultCtorArgType) : \
  37. GenComplex(DefaultCtorArgType()) { \
  38. set_all_attributes_as_default_or_unset(); \
  39. set_all_custom_attributes_to_default(); \
  40. }
  41. class GenComplex: public BaseDataClass {
  42. public:
  43. GenComplex() {
  44. }
  45. GenComplex(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<Complex> copy_complex() const;
  52. std::shared_ptr<Complex> deepcopy_complex(py::dict = py::dict()) const;
  53. virtual bool __eq__(const Complex& other) const;
  54. virtual bool eq_nonarray_attributes(const Complex& other, const bool ignore_name = false) const;
  55. bool operator == (const Complex& other) const { return __eq__(other);}
  56. bool operator != (const Complex& 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. virtual std::string export_vec_elementary_molecules(std::ostream& out, PythonExportContext& ctx, const std::string& parent_name);
  60. // --- attributes ---
  61. std::vector<std::shared_ptr<ElementaryMolecule>> elementary_molecules;
  62. virtual void set_elementary_molecules(const std::vector<std::shared_ptr<ElementaryMolecule>> new_elementary_molecules_) {
  63. if (initialized) {
  64. throw RuntimeError("Value 'elementary_molecules' of object with name " + name + " (class " + class_name + ") "
  65. "cannot be set after model was initialized.");
  66. }
  67. cached_data_are_uptodate = false;
  68. elementary_molecules = new_elementary_molecules_;
  69. }
  70. virtual std::vector<std::shared_ptr<ElementaryMolecule>>& get_elementary_molecules() {
  71. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  72. return elementary_molecules;
  73. }
  74. Orientation orientation;
  75. virtual void set_orientation(const Orientation new_orientation_) {
  76. if (initialized) {
  77. throw RuntimeError("Value 'orientation' of object with name " + name + " (class " + class_name + ") "
  78. "cannot be set after model was initialized.");
  79. }
  80. cached_data_are_uptodate = false;
  81. orientation = new_orientation_;
  82. }
  83. virtual Orientation get_orientation() const {
  84. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  85. return orientation;
  86. }
  87. std::string compartment_name;
  88. virtual void set_compartment_name(const std::string& new_compartment_name_) {
  89. if (initialized) {
  90. throw RuntimeError("Value 'compartment_name' of object with name " + name + " (class " + class_name + ") "
  91. "cannot be set after model was initialized.");
  92. }
  93. cached_data_are_uptodate = false;
  94. compartment_name = new_compartment_name_;
  95. }
  96. virtual const std::string& get_compartment_name() const {
  97. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  98. return compartment_name;
  99. }
  100. // --- methods ---
  101. virtual std::string to_bngl_str() const = 0;
  102. virtual std::shared_ptr<Species> as_species() = 0;
  103. }; // GenComplex
  104. class Complex;
  105. py::class_<Complex> define_pybinding_Complex(py::module& m);
  106. } // namespace API
  107. } // namespace MCell
  108. #endif // API_GEN_COMPLEX_H