State.cpp 984 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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<ls_std::StateConnectionId, 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::_stateIsConnected(const std::string &_id)
  31. {
  32. return this->connectedStates.find(_id) != this->connectedStates.end();
  33. }