PityTest11 is a very flexible C++11 peer-to-peer test framework supporting hierarchically structured test suites, multi-processing, logging, IPC, synchronization and more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.4 KiB

  1. #include "PityPerspective.hh"
  2. #include "PityModel.hh"
  3. namespace pEp {
  4. namespace PityTest11 {
  5. bool PityPerspective::debug_log_enabled = false;
  6. PityPerspective::PityPerspective(const PityModel& model) : model{ model }, peerNrAsCpt{ 0 }
  7. {
  8. pEpLogClass("called");
  9. }
  10. TestIdent* PityPerspective::getPeer(const std::string& addr)
  11. {
  12. for (int i = 0; i < peers.size(); i++) {
  13. if (peers.at(i).addr == addr) {
  14. return &peers.at(i);
  15. }
  16. }
  17. throw std::invalid_argument("getPeer(+" + addr + ") - not found");
  18. }
  19. void PityPerspective::setPeerNrAsCpt(int nr)
  20. {
  21. if (nr < peers.size()) {
  22. peerNrAsCpt = nr;
  23. } else {
  24. throw std::invalid_argument("setPeerNrAsCpt(" + std::to_string(nr) + ") - out of range");
  25. }
  26. }
  27. TestIdent& PityPerspective::getCpt()
  28. {
  29. return peers.at(peerNrAsCpt);
  30. }
  31. Group* PityPerspective::getGroup(const std::string& addr)
  32. {
  33. for (int i = 0; i < groups.size(); i++) {
  34. if (groups.at(i).addr == addr) {
  35. return &groups.at(i);
  36. }
  37. }
  38. throw std::invalid_argument("getGroup(" + addr + ") - not found");
  39. }
  40. } // namespace PityTest11
  41. } // namespace pEp