SystemTime.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Author: Patrick-Christopher Mattulat
  3. * Company: Lynar Studios
  4. * E-Mail: webmaster@lynarstudios.com
  5. * Created: 2023-03-15
  6. * Changed: 2023-03-15
  7. *
  8. * */
  9. #include <ls-std/core/Class.hpp>
  10. #include <ls-std/core/evaluator/NullPointerArgumentEvaluator.hpp>
  11. #include <ls-std/time/system-time/PosixClock.hpp>
  12. #include <ls-std/time/system-time/SystemTime.hpp>
  13. #include <ls-std/time/system-time/SystemTimeParameter.hpp>
  14. #include <memory>
  15. using ls::std::core::Class;
  16. using ls::std::core::NullPointerArgumentEvaluator;
  17. using ls::std::time::PosixClock;
  18. using ls::std::time::SystemTime;
  19. using ls::std::time::SystemTimeParameter;
  20. using std::make_shared;
  21. using std::shared_ptr;
  22. SystemTime::SystemTime(const shared_ptr<SystemTimeParameter> &_parameter) : SystemTime()
  23. {
  24. NullPointerArgumentEvaluator{_parameter}.evaluate();
  25. this->parameter = _parameter;
  26. }
  27. SystemTime::SystemTime() : Class("SystemTime")
  28. {
  29. this->_generateParameter();
  30. }
  31. SystemTime::~SystemTime() noexcept = default;
  32. bool SystemTime::set(uint32_t _timeStamp)
  33. {
  34. return this->parameter->getPosixClock()->setTime(_timeStamp);
  35. }
  36. void SystemTime::_generateParameter()
  37. {
  38. this->parameter = make_shared<SystemTimeParameter>();
  39. this->parameter->setPosixClock(make_shared<PosixClock>());
  40. }