1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- #include <ls-std/core/Class.hpp>
- #include <ls-std/core/evaluator/NullPointerArgumentEvaluator.hpp>
- #if defined(unix) || defined(__APPLE__)
- #include <ls-std/time/system-time/PosixClock.hpp>
- #endif
- #include <ls-std/time/system-time/SystemTime.hpp>
- #include <ls-std/time/system-time/SystemTimeParameter.hpp>
- #ifdef _WIN32
- #include <ls-std/time/system-time/WindowsClock.hpp>
- #endif
- #include <memory>
- using ls::std::core::Class;
- using ls::std::core::NullPointerArgumentEvaluator;
- using ls::std::time::DateParameter;
- #if defined(unix) || defined(__APPLE__)
- using ls::std::time::PosixClock;
- #endif
- using ls::std::time::SystemTime;
- using ls::std::time::SystemTimeParameter;
- #ifdef _WIN32
- using ls::std::time::WindowsClock;
- #endif
- using ls::std::time::type::UnixTimestamp;
- using std::make_shared;
- using std::shared_ptr;
- using std::string;
- SystemTime::SystemTime(const shared_ptr<SystemTimeParameter> &_parameter) : Class(SystemTime::_fetchClassName()), parameter(_parameter)
- {
- NullPointerArgumentEvaluator{_parameter}.evaluate();
- }
- SystemTime::SystemTime() : Class(SystemTime::_fetchClassName())
- {
- this->_generateParameter();
- }
- SystemTime::~SystemTime() noexcept = default;
- bool SystemTime::set(const DateParameter &_dateParameter) const
- {
- return this->parameter->getClock()->setTime(_dateParameter);
- }
- string SystemTime::_fetchClassName()
- {
- static const string className = "SystemTime";
- return className;
- }
- void SystemTime::_generateParameter()
- {
- this->parameter = make_shared<SystemTimeParameter>();
- #if defined(unix) || defined(__APPLE__)
- this->parameter->setClock(make_shared<PosixClock>());
- #endif
- #ifdef _WIN32
- this->parameter->setClock(make_shared<WindowsClock>());
- #endif
- }
|