Event.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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-08
  7. *
  8. * */
  9. #include <ls-std/core/evaluator/EmptyStringArgumentEvaluator.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. ls::std::core::EmptyStringArgumentEvaluator{_id, "event id is empty!"}.evaluate();
  48. this->id = _id;
  49. }
  50. bool ls::std::event::Event::_hasParameter(const ls::std::core::type::event_id &_id)
  51. {
  52. return this->parameterList.find(_id) != this->parameterList.end();
  53. }