component.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 "api/component.h"
  12. #include "api/component_type.h"
  13. using namespace std;
  14. namespace MCell {
  15. namespace API {
  16. bool Component::operator < (const Component& other) const {
  17. if (name != other.name) {
  18. return name < other.name;
  19. }
  20. if (state != other.state) {
  21. return state < other.state;
  22. }
  23. return bond < other.bond;
  24. }
  25. std::string Component::to_bngl_str() const {
  26. std::string res;
  27. res = component_type->name;
  28. if (state != STATE_UNSET) {
  29. res += "~" + state;
  30. }
  31. if (bond != BOND_UNBOUND) {
  32. if (bond == BOND_BOUND) {
  33. res += "!+";
  34. }
  35. else if (bond == BOND_ANY) {
  36. res += "!?";
  37. }
  38. else {
  39. res += "!" + std::to_string(bond);
  40. }
  41. }
  42. return res;
  43. }
  44. } // namespace API
  45. } // namespace MCell