gen_subsystem.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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_SUBSYSTEM_H
  12. #define API_GEN_SUBSYSTEM_H
  13. #include "api/api_common.h"
  14. #include "api/base_export_class.h"
  15. namespace MCell {
  16. namespace API {
  17. class Subsystem;
  18. class ElementaryMoleculeType;
  19. class ReactionRule;
  20. class Species;
  21. class SurfaceClass;
  22. class PythonExportContext;
  23. #define SUBSYSTEM_CTOR() \
  24. Subsystem( \
  25. const std::vector<std::shared_ptr<Species>> species_ = std::vector<std::shared_ptr<Species>>(), \
  26. const std::vector<std::shared_ptr<ReactionRule>> reaction_rules_ = std::vector<std::shared_ptr<ReactionRule>>(), \
  27. const std::vector<std::shared_ptr<SurfaceClass>> surface_classes_ = std::vector<std::shared_ptr<SurfaceClass>>(), \
  28. const std::vector<std::shared_ptr<ElementaryMoleculeType>> elementary_molecule_types_ = std::vector<std::shared_ptr<ElementaryMoleculeType>>() \
  29. ) { \
  30. species = species_; \
  31. reaction_rules = reaction_rules_; \
  32. surface_classes = surface_classes_; \
  33. elementary_molecule_types = elementary_molecule_types_; \
  34. } \
  35. Subsystem(DefaultCtorArgType){ \
  36. }
  37. class GenSubsystem: public BaseExportClass {
  38. public:
  39. GenSubsystem() {
  40. }
  41. GenSubsystem(DefaultCtorArgType) {
  42. }
  43. virtual ~GenSubsystem() {}
  44. std::shared_ptr<Subsystem> copy_subsystem() const;
  45. std::shared_ptr<Subsystem> deepcopy_subsystem(py::dict = py::dict()) const;
  46. virtual bool __eq__(const Subsystem& other) const;
  47. virtual bool eq_nonarray_attributes(const Subsystem& other, const bool ignore_name = false) const;
  48. bool operator == (const Subsystem& other) const { return __eq__(other);}
  49. bool operator != (const Subsystem& other) const { return !__eq__(other);}
  50. std::string to_str(const bool all_details=false, const std::string ind="") const ;
  51. virtual std::string export_to_python(std::ostream& out, PythonExportContext& ctx);
  52. virtual std::string export_vec_species(std::ostream& out, PythonExportContext& ctx, const std::string& parent_name);
  53. virtual std::string export_vec_reaction_rules(std::ostream& out, PythonExportContext& ctx, const std::string& parent_name);
  54. virtual std::string export_vec_surface_classes(std::ostream& out, PythonExportContext& ctx, const std::string& parent_name);
  55. virtual std::string export_vec_elementary_molecule_types(std::ostream& out, PythonExportContext& ctx, const std::string& parent_name);
  56. // --- attributes ---
  57. std::vector<std::shared_ptr<Species>> species;
  58. virtual void set_species(const std::vector<std::shared_ptr<Species>> new_species_) {
  59. species = new_species_;
  60. }
  61. virtual std::vector<std::shared_ptr<Species>>& get_species() {
  62. return species;
  63. }
  64. std::vector<std::shared_ptr<ReactionRule>> reaction_rules;
  65. virtual void set_reaction_rules(const std::vector<std::shared_ptr<ReactionRule>> new_reaction_rules_) {
  66. reaction_rules = new_reaction_rules_;
  67. }
  68. virtual std::vector<std::shared_ptr<ReactionRule>>& get_reaction_rules() {
  69. return reaction_rules;
  70. }
  71. std::vector<std::shared_ptr<SurfaceClass>> surface_classes;
  72. virtual void set_surface_classes(const std::vector<std::shared_ptr<SurfaceClass>> new_surface_classes_) {
  73. surface_classes = new_surface_classes_;
  74. }
  75. virtual std::vector<std::shared_ptr<SurfaceClass>>& get_surface_classes() {
  76. return surface_classes;
  77. }
  78. std::vector<std::shared_ptr<ElementaryMoleculeType>> elementary_molecule_types;
  79. virtual void set_elementary_molecule_types(const std::vector<std::shared_ptr<ElementaryMoleculeType>> new_elementary_molecule_types_) {
  80. elementary_molecule_types = new_elementary_molecule_types_;
  81. }
  82. virtual std::vector<std::shared_ptr<ElementaryMoleculeType>>& get_elementary_molecule_types() {
  83. return elementary_molecule_types;
  84. }
  85. // --- methods ---
  86. virtual void add_species(std::shared_ptr<Species> s) = 0;
  87. virtual std::shared_ptr<Species> find_species(const std::string& name) = 0;
  88. virtual void add_reaction_rule(std::shared_ptr<ReactionRule> r) = 0;
  89. virtual std::shared_ptr<ReactionRule> find_reaction_rule(const std::string& name) = 0;
  90. virtual void add_surface_class(std::shared_ptr<SurfaceClass> sc) = 0;
  91. virtual std::shared_ptr<SurfaceClass> find_surface_class(const std::string& name) = 0;
  92. virtual void add_elementary_molecule_type(std::shared_ptr<ElementaryMoleculeType> mt) = 0;
  93. virtual std::shared_ptr<ElementaryMoleculeType> find_elementary_molecule_type(const std::string& name) = 0;
  94. virtual void load_bngl_molecule_types_and_reaction_rules(const std::string& file_name, const std::map<std::string, double>& parameter_overrides = std::map<std::string, double>()) = 0;
  95. }; // GenSubsystem
  96. class Subsystem;
  97. py::class_<Subsystem> define_pybinding_Subsystem(py::module& m);
  98. } // namespace API
  99. } // namespace MCell
  100. #endif // API_GEN_SUBSYSTEM_H