base_export_class.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /******************************************************************************
  2. *
  3. * Copyright (C) 2020 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 LIBMCELL_API_BASE_EXPORT_CLASS_H_
  12. #define LIBMCELL_API_BASE_EXPORT_CLASS_H_
  13. #include "api/api_common.h"
  14. namespace MCell {
  15. namespace API {
  16. class PythonExportContext;
  17. // base class for all classes that provide export to python
  18. class BaseExportClass {
  19. public:
  20. virtual ~BaseExportClass() {
  21. }
  22. // may be overridden by the final class if needed
  23. virtual void set_all_custom_attributes_to_default() {
  24. }
  25. // used in generated export_to_python to optionally skip export of some objects
  26. virtual bool skip_python_export() const {
  27. return false;
  28. }
  29. // do not export vectors (used in Complex class)
  30. virtual bool skip_vectors_export() const {
  31. return false;
  32. }
  33. // export as a string without newlines (used in Complex class),
  34. // may not be applied to exported vectors
  35. virtual bool export_as_string_without_newlines() const {
  36. return false;
  37. }
  38. // do not check if already exported
  39. virtual bool export_even_if_already_exported() const {
  40. return false;
  41. }
  42. // either returns the whole definition as a string or prints definition to out and
  43. // returns name
  44. virtual std::string export_to_python(std::ostream& out, PythonExportContext& ctx) {
  45. assert(false);
  46. return "Export to Python for a derived class is not implemented.";
  47. }
  48. };
  49. } // namespace API
  50. } // namespace MCell
  51. #endif /* LIBMCELL_API_BASE_EXPORT_CLASS_H_ */