gen_observables.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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_OBSERVABLES_H
  12. #define API_GEN_OBSERVABLES_H
  13. #include "api/api_common.h"
  14. #include "api/base_export_class.h"
  15. namespace MCell {
  16. namespace API {
  17. class Observables;
  18. class Count;
  19. class VizOutput;
  20. class PythonExportContext;
  21. #define OBSERVABLES_CTOR() \
  22. Observables( \
  23. const std::vector<std::shared_ptr<VizOutput>> viz_outputs_ = std::vector<std::shared_ptr<VizOutput>>(), \
  24. const std::vector<std::shared_ptr<Count>> counts_ = std::vector<std::shared_ptr<Count>>() \
  25. ) { \
  26. viz_outputs = viz_outputs_; \
  27. counts = counts_; \
  28. } \
  29. Observables(DefaultCtorArgType){ \
  30. }
  31. class GenObservables: public BaseExportClass {
  32. public:
  33. GenObservables() {
  34. }
  35. GenObservables(DefaultCtorArgType) {
  36. }
  37. virtual ~GenObservables() {}
  38. std::shared_ptr<Observables> copy_observables() const;
  39. std::shared_ptr<Observables> deepcopy_observables(py::dict = py::dict()) const;
  40. virtual bool __eq__(const Observables& other) const;
  41. virtual bool eq_nonarray_attributes(const Observables& other, const bool ignore_name = false) const;
  42. bool operator == (const Observables& other) const { return __eq__(other);}
  43. bool operator != (const Observables& other) const { return !__eq__(other);}
  44. std::string to_str(const bool all_details=false, const std::string ind="") const ;
  45. virtual std::string export_to_python(std::ostream& out, PythonExportContext& ctx);
  46. virtual std::string export_vec_viz_outputs(std::ostream& out, PythonExportContext& ctx, const std::string& parent_name);
  47. virtual std::string export_vec_counts(std::ostream& out, PythonExportContext& ctx, const std::string& parent_name);
  48. // --- attributes ---
  49. std::vector<std::shared_ptr<VizOutput>> viz_outputs;
  50. virtual void set_viz_outputs(const std::vector<std::shared_ptr<VizOutput>> new_viz_outputs_) {
  51. viz_outputs = new_viz_outputs_;
  52. }
  53. virtual std::vector<std::shared_ptr<VizOutput>>& get_viz_outputs() {
  54. return viz_outputs;
  55. }
  56. std::vector<std::shared_ptr<Count>> counts;
  57. virtual void set_counts(const std::vector<std::shared_ptr<Count>> new_counts_) {
  58. counts = new_counts_;
  59. }
  60. virtual std::vector<std::shared_ptr<Count>>& get_counts() {
  61. return counts;
  62. }
  63. // --- methods ---
  64. virtual void add_viz_output(std::shared_ptr<VizOutput> viz_output) = 0;
  65. virtual void add_count(std::shared_ptr<Count> count) = 0;
  66. virtual std::shared_ptr<Count> find_count(const std::string& name) = 0;
  67. virtual void load_bngl_observables(const std::string& file_name, const std::string& observables_path_or_file = STR_UNSET, const std::map<std::string, double>& parameter_overrides = std::map<std::string, double>(), const CountOutputFormat observables_output_format = CountOutputFormat::AUTOMATIC_FROM_EXTENSION) = 0;
  68. }; // GenObservables
  69. class Observables;
  70. py::class_<Observables> define_pybinding_Observables(py::module& m);
  71. } // namespace API
  72. } // namespace MCell
  73. #endif // API_GEN_OBSERVABLES_H