Event.cpp 1.6 KB

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