State.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-09-05
  6. * Changed: 2020-09-10
  7. *
  8. * */
  9. #include "State.hpp"
  10. ls_std::State::State(std::string _id) : Class("State"),
  11. id(std::move(_id))
  12. {}
  13. bool ls_std::State::addStateConnection(const std::string& _connectionId, const std::shared_ptr<State>& _connectedState)
  14. {
  15. bool added {};
  16. if(_connectedState != nullptr && !this->_stateIsConnected(_connectionId)) {
  17. this->connectedStates.insert({_connectionId, _connectedState});
  18. added = true;
  19. }
  20. return added;
  21. }
  22. std::unordered_map<std::string, std::shared_ptr<ls_std::State>> ls_std::State::getConnectedStates()
  23. {
  24. return this->connectedStates;
  25. }
  26. std::string ls_std::State::getId()
  27. {
  28. return this->id;
  29. }
  30. bool ls_std::State::isAccessible() const
  31. {
  32. return this->accessCondition;
  33. }
  34. void ls_std::State::updateAccessCondition(bool _enteredCondition)
  35. {
  36. this->accessCondition = _enteredCondition;
  37. }
  38. bool ls_std::State::_stateIsConnected(const std::string &_id)
  39. {
  40. return this->connectedStates.find(_id) != this->connectedStates.end();
  41. }