Event.cpp 1.3 KB

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