gen_warnings.h 3.6 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_WARNINGS_H
  12. #define API_GEN_WARNINGS_H
  13. #include "api/api_common.h"
  14. #include "api/base_data_class.h"
  15. namespace MCell {
  16. namespace API {
  17. class Warnings;
  18. class PythonExportContext;
  19. #define WARNINGS_CTOR() \
  20. Warnings( \
  21. const WarningLevel high_reaction_probability_ = WarningLevel::IGNORE, \
  22. const WarningLevel molecule_placement_failure_ = WarningLevel::ERROR \
  23. ) { \
  24. class_name = "Warnings"; \
  25. high_reaction_probability = high_reaction_probability_; \
  26. molecule_placement_failure = molecule_placement_failure_; \
  27. postprocess_in_ctor(); \
  28. check_semantics(); \
  29. } \
  30. Warnings(DefaultCtorArgType) : \
  31. GenWarnings(DefaultCtorArgType()) { \
  32. set_all_attributes_as_default_or_unset(); \
  33. set_all_custom_attributes_to_default(); \
  34. }
  35. class GenWarnings: public BaseDataClass {
  36. public:
  37. GenWarnings() {
  38. }
  39. GenWarnings(DefaultCtorArgType) {
  40. }
  41. void postprocess_in_ctor() override {}
  42. void check_semantics() const override;
  43. void set_initialized() override;
  44. void set_all_attributes_as_default_or_unset() override;
  45. std::shared_ptr<Warnings> copy_warnings() const;
  46. std::shared_ptr<Warnings> deepcopy_warnings(py::dict = py::dict()) const;
  47. virtual bool __eq__(const Warnings& other) const;
  48. virtual bool eq_nonarray_attributes(const Warnings& other, const bool ignore_name = false) const;
  49. bool operator == (const Warnings& other) const { return __eq__(other);}
  50. bool operator != (const Warnings& other) const { return !__eq__(other);}
  51. std::string to_str(const bool all_details=false, const std::string ind="") const override;
  52. std::string export_to_python(std::ostream& out, PythonExportContext& ctx) override;
  53. // --- attributes ---
  54. WarningLevel high_reaction_probability;
  55. virtual void set_high_reaction_probability(const WarningLevel new_high_reaction_probability_) {
  56. if (initialized) {
  57. throw RuntimeError("Value 'high_reaction_probability' of object with name " + name + " (class " + class_name + ") "
  58. "cannot be set after model was initialized.");
  59. }
  60. cached_data_are_uptodate = false;
  61. high_reaction_probability = new_high_reaction_probability_;
  62. }
  63. virtual WarningLevel get_high_reaction_probability() const {
  64. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  65. return high_reaction_probability;
  66. }
  67. WarningLevel molecule_placement_failure;
  68. virtual void set_molecule_placement_failure(const WarningLevel new_molecule_placement_failure_) {
  69. if (initialized) {
  70. throw RuntimeError("Value 'molecule_placement_failure' of object with name " + name + " (class " + class_name + ") "
  71. "cannot be set after model was initialized.");
  72. }
  73. cached_data_are_uptodate = false;
  74. molecule_placement_failure = new_molecule_placement_failure_;
  75. }
  76. virtual WarningLevel get_molecule_placement_failure() const {
  77. cached_data_are_uptodate = false; // arrays and other data can be modified through getters
  78. return molecule_placement_failure;
  79. }
  80. // --- methods ---
  81. }; // GenWarnings
  82. class Warnings;
  83. py::class_<Warnings> define_pybinding_Warnings(py::module& m);
  84. } // namespace API
  85. } // namespace MCell
  86. #endif // API_GEN_WARNINGS_H