molecule.cpp 862 B

123456789101112131415161718192021222324252627282930313233343536
  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. #include "molecule.h"
  12. #include "world.h"
  13. #include "partition.h"
  14. namespace MCell {
  15. namespace API {
  16. void Molecule::remove() {
  17. check_initialization();
  18. Partition& p = world->get_partition(PARTITION_ID_INITIAL);
  19. if (!p.does_molecule_exist(id)) {
  20. throw RuntimeError("Molecule with id " + std::to_string(id) + " does not exist anymore.");
  21. }
  22. // set that this molecule is defunct
  23. world->get_partition(PARTITION_ID_INITIAL).get_m(id).set_is_defunct();
  24. }
  25. }
  26. }