Event.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2020-11-26
  6. * Changed: 2021-07-14
  7. *
  8. * */
  9. #include <ls_std/event/Event.hpp>
  10. #include <ls_std/exception/IllegalArgumentException.hpp>
  11. ls_std::Event::Event(const ls_std::event_id &_id) : ls_std::Class("Event")
  12. {
  13. this->_assignId(_id);
  14. }
  15. bool ls_std::Event::addParameter(const ls_std::event_parameter &_eventParameter)
  16. {
  17. bool wasAdded{};
  18. if (!this->_hasParameter(_eventParameter.first))
  19. {
  20. wasAdded = this->parameterList.insert(_eventParameter).second;
  21. }
  22. return wasAdded;
  23. }
  24. void ls_std::Event::clearParameterList()
  25. {
  26. this->parameterList.clear();
  27. }
  28. ls_std::event_id ls_std::Event::getId()
  29. {
  30. return this->id;
  31. }
  32. ls_std::event_parameter_list ls_std::Event::getParameterList()
  33. {
  34. return this->parameterList;
  35. }
  36. bool ls_std::Event::removeParameter(const ls_std::event_parameter_id &_id)
  37. {
  38. return this->parameterList.erase(_id) == 1;
  39. }
  40. void ls_std::Event::setId(const ls_std::event_id &_id)
  41. {
  42. this->_assignId(_id);
  43. }
  44. void ls_std::Event::_assignId(const ls_std::event_id &_id)
  45. {
  46. if (_id.empty())
  47. {
  48. throw ls_std::IllegalArgumentException{};
  49. }
  50. this->id = _id;
  51. }
  52. bool ls_std::Event::_hasParameter(const ls_std::event_id &_id)
  53. {
  54. return this->parameterList.find(_id) != this->parameterList.end();
  55. }