gen_instantiation.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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_INSTANTIATION_H
  12. #define API_GEN_INSTANTIATION_H
  13. #include "api/api_common.h"
  14. #include "api/base_export_class.h"
  15. namespace MCell {
  16. namespace API {
  17. class Instantiation;
  18. class BaseChkptMol;
  19. class GeometryObject;
  20. class Region;
  21. class ReleaseSite;
  22. class PythonExportContext;
  23. #define INSTANTIATION_CTOR() \
  24. Instantiation( \
  25. const std::vector<std::shared_ptr<ReleaseSite>> release_sites_ = std::vector<std::shared_ptr<ReleaseSite>>(), \
  26. const std::vector<std::shared_ptr<GeometryObject>> geometry_objects_ = std::vector<std::shared_ptr<GeometryObject>>(), \
  27. const std::vector<std::shared_ptr<BaseChkptMol>> checkpointed_molecules_ = std::vector<std::shared_ptr<BaseChkptMol>>() \
  28. ) { \
  29. release_sites = release_sites_; \
  30. geometry_objects = geometry_objects_; \
  31. checkpointed_molecules = checkpointed_molecules_; \
  32. } \
  33. Instantiation(DefaultCtorArgType){ \
  34. }
  35. class GenInstantiation: public BaseExportClass {
  36. public:
  37. GenInstantiation() {
  38. }
  39. GenInstantiation(DefaultCtorArgType) {
  40. }
  41. virtual ~GenInstantiation() {}
  42. std::shared_ptr<Instantiation> copy_instantiation() const;
  43. std::shared_ptr<Instantiation> deepcopy_instantiation(py::dict = py::dict()) const;
  44. virtual bool __eq__(const Instantiation& other) const;
  45. virtual bool eq_nonarray_attributes(const Instantiation& other, const bool ignore_name = false) const;
  46. bool operator == (const Instantiation& other) const { return __eq__(other);}
  47. bool operator != (const Instantiation& other) const { return !__eq__(other);}
  48. std::string to_str(const bool all_details=false, const std::string ind="") const ;
  49. virtual std::string export_to_python(std::ostream& out, PythonExportContext& ctx);
  50. virtual std::string export_vec_release_sites(std::ostream& out, PythonExportContext& ctx, const std::string& parent_name);
  51. virtual std::string export_vec_geometry_objects(std::ostream& out, PythonExportContext& ctx, const std::string& parent_name);
  52. virtual std::string export_vec_checkpointed_molecules(std::ostream& out, PythonExportContext& ctx, const std::string& parent_name);
  53. // --- attributes ---
  54. std::vector<std::shared_ptr<ReleaseSite>> release_sites;
  55. virtual void set_release_sites(const std::vector<std::shared_ptr<ReleaseSite>> new_release_sites_) {
  56. release_sites = new_release_sites_;
  57. }
  58. virtual std::vector<std::shared_ptr<ReleaseSite>>& get_release_sites() {
  59. return release_sites;
  60. }
  61. std::vector<std::shared_ptr<GeometryObject>> geometry_objects;
  62. virtual void set_geometry_objects(const std::vector<std::shared_ptr<GeometryObject>> new_geometry_objects_) {
  63. geometry_objects = new_geometry_objects_;
  64. }
  65. virtual std::vector<std::shared_ptr<GeometryObject>>& get_geometry_objects() {
  66. return geometry_objects;
  67. }
  68. std::vector<std::shared_ptr<BaseChkptMol>> checkpointed_molecules;
  69. virtual void set_checkpointed_molecules(const std::vector<std::shared_ptr<BaseChkptMol>> new_checkpointed_molecules_) {
  70. checkpointed_molecules = new_checkpointed_molecules_;
  71. }
  72. virtual std::vector<std::shared_ptr<BaseChkptMol>>& get_checkpointed_molecules() {
  73. return checkpointed_molecules;
  74. }
  75. // --- methods ---
  76. virtual void add_release_site(std::shared_ptr<ReleaseSite> s) = 0;
  77. virtual std::shared_ptr<ReleaseSite> find_release_site(const std::string& name) = 0;
  78. virtual void add_geometry_object(std::shared_ptr<GeometryObject> o) = 0;
  79. virtual std::shared_ptr<GeometryObject> find_geometry_object(const std::string& name) = 0;
  80. virtual std::shared_ptr<GeometryObject> find_volume_compartment_object(const std::string& name) = 0;
  81. virtual std::shared_ptr<GeometryObject> find_surface_compartment_object(const std::string& name) = 0;
  82. virtual void load_bngl_compartments_and_seed_species(const std::string& file_name, std::shared_ptr<Region> default_release_region = nullptr, const std::map<std::string, double>& parameter_overrides = std::map<std::string, double>()) = 0;
  83. }; // GenInstantiation
  84. class Instantiation;
  85. py::class_<Instantiation> define_pybinding_Instantiation(py::module& m);
  86. } // namespace API
  87. } // namespace MCell
  88. #endif // API_GEN_INSTANTIATION_H